Macro to add word to existing text in different worksbooks

M

Mifty

Hi,

I'm using a recorded macro which carries out the same set of instructions
for about 50 different workbooks.

My problem is when I've added a bit more to save having to add a word to
existing text manually. The text in each workbook is different but I want to
add "Provisional" at the end.

When I recorded it I just clicked into the cell and pressed F2 and added
text at end but when I looked at the macro it's copying the whole of the line
of text.

If anyone could help with this that would be brilliant

Cheers
 
M

Mifty

Hi Barb,

I'm just learning (picking it all up from having a go, forums like these and
websites) so never sure if I'm doing ok or not.

I'd got rid of the lines that were replacing my text so have just
re-recorded this bit.
In my recorded code it has picked up the name of the organisation whose
workbook I recorded the macro on so I have replaced with xxxxx here just in
case I breach any confidential stuff (hope that's ok)

Application.Run "PERSONAL.XLS!BenchPickIfs"
Range("A4:J4").Select
ActiveCell.FormulaR1C1 = _
"'Results for 2007 xxxxxxxxxxx [Provisional]"
With ActiveCell.Characters(Start:=1, Length:=85).Font
.Name = "Lucida Sans"
.FontStyle = "Bold"
.Size = 8
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
End With
End Sub

These are the lines that I have removed

ActiveCell.FormulaR1C1 = _
"'Results for 2007 XXXXXXX [Provisional]"

So what I want to do is just add [Provisional] after xxxxxx which will be
different on each of the workbooks. Not explaining myself too well :-(

Is the code after these two lines just formatting that I could delete to
tidy the code? Not aiming to do that sort of thing now. Just want usable code
but nice to know from someone who understands this stuff.

Many thanks
 
G

Gary''s Student

Select the cells and run:

Sub prov()
For Each r In Selection
r.Value = r.Value & " Provisional"
Next
End Sub
 
M

Mifty

Many thanks :)))))
--
Mifty


Gary''s Student said:
Select the cells and run:

Sub prov()
For Each r In Selection
r.Value = r.Value & " Provisional"
Next
End Sub
 

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