Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
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 :)


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro error - cant work it out... NPell Excel Worksheet Functions 3 February 23rd 09 01:15 PM
Why does the Selection not work Sunnyskies Excel Discussion (Misc queries) 2 October 5th 07 07:31 AM
Macro error-"Selection is too large" CEG Excel Programming 0 February 17th 06 05:31 PM
Macro does not work after the program has been restarted in excel.Run time error 2147417848 (80010108) Method visible of object_worksheet failed [email protected] Excel Programming 7 August 24th 05 03:11 PM
Excel Macro Problem, Add-in need to work in every workbook & Error:9 Subscript out of range Burak[_2_] Excel Programming 1 October 31st 03 08:09 PM


All times are GMT +1. The time now is 10:12 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"