View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
JLGWhiz JLGWhiz is offline
external usenet poster
 
Posts: 3,986
Default What's my error? - S&R macro to work on any selection, from a mast

I can't test this but, you can try it. I changed a couple of things in your
code:

Sub replacingAvalueswithBtext()
Dim S As Range

LR = Range("A65536").End(xlUp).Row
For Each S In Worksheets("s&r").Range("A1",LR)
Selection.Replace What:=S.Value, Replacement:=S.Offset(0, 1).Value,
LookAt:=xlWhole, SearchOrder:=xlByColumns, MatchCase:=False
Next S
End Sub



"Avel" wrote:

Hi all,

Tried to reply to an existing discussion topic but it didn't take -

I am not much of a programmer, but I have successfully dabbled with VBA
in Excel now and again over the years. I am now trying to run a piece
of code to take a master list of two columns of data, col A being the
original number strings, and col B the replacement text descriptions
that I want to swap in, and run the S&R on all cells I had selected in
a different worksheet/workbook.

I thought the below would work, but it doesn't - what am I doing wrong?

Sub replacingAvalueswithBtext()
Dim S

For Each S In Worksheets("s&r").Range("A1",
Range("A65536").End(xlUp).Address)
Selection.Replace What:=S.Text, Replacement:=S.Offset(0, 1).Text,
LookAt:=xlWhole, SearchOrder:=xlByColumns, MatchCase:=True
Next S
End Sub

Any help much appreciated, or am I just barking up the wrong tree with
this? Direct email replies appreciated too, as I am not sure I've
subscribed correctly!

Thanks in advance for any assistance :)