How do I add additional text in many cells

G

Guest

Hello,

I'd like to know how I can insert the same additional text to cells when
there is already text in these cells without having to type it in every cell
separately:
H1/1
H7/2
H8/3
should read
H1/1_9.11
H7/2_9.11
H8/3_9.11

Thanks

Markus
 
G

Guest

Hi,

One way. Right cleck the sheet tab, view code and paste this in. Select the
range where your data are and then run this code:-

Sub addtext()
newtext = "_9.11"
Set myrange = Selection
For Each c In myrange
If c.Value = "H1/1" Or c.Value = "H7/2" Or c.Value = "H8/3" _
Then c.Value = c.Value & newtext
Next
End Sub

Mike
 
G

Guest

Hi Mike,

I have about a 100 cells with different text so if I have to type
"If c.Value = "H1/1" Or c.Value = "H7/2" Or c.Value = "H8/3" _
Then c.Value = c.Value & newtext"
the contents of each cell in the macro program then it's quicker to manually
paste the text in each cell. Or is there another way?

Thanks Markus
 
G

Gord Dibben

Sub addtext()
newtext = "_9.11"
Set myrange = Selection
For Each c In myrange
c.Value = c.Value & newtext
Next c
End Sub


Gord Dibben MS Excel MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top