View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default Copying Variables in VB Editor In Excel


Sub ReplaceItems()
Dim sh As Worksheet
Dim str As String
sStr = InputBox("enter item to be replaced")
sStr1 = InputBox("enter replacement")
Application.displayalerts = False
For Each sh In Worksheets(Array("sheet1", "sheet2", . . . , _
"sheet9","sheet10"))
sh.Cells.Replace What:=sStr, Replacement:=sStr1, _
LookAt:=xlPart, SearchOrder:=xlByRows, MatchCase:=False
Next
Application.displayalerts = True
End Sub

replace ... with the list of additional sheet names.

--
Regards,
Tom Ogilvy


Tony wrote in message
...
Hi

Am not hot on VB and am stuck. Have recorded a macro
which uses text written into a box, running the macro to
run a mass replace job over 10 sheets. When I do this,
everything works apart from the macro always replaces
what was originally in the box rather than whatever is
typed. How do I change this constant into a variable
copy/paste? Please keep it simple if you can help!!!

Thank you for any help you can give

Tony