Excel VBA Range Scope for Find/Replace

TorontoNewf

New Member
Joined
Nov 14, 2016
Messages
20
Greetings,

I am interested in doing a Find/Replace on a specific range.
Controlling the scope to Worksheet vs Workbook seems to be my issue.

Doing a regular replace produces inconsistent results:
Selection.Replace _
what:="abc", Replacement:="xxx", _
LookAt:=xlPart, SearchOrder:=xlByRows, MatchCase:=False, _
SearchFormat:=False, ReplaceFormat:=False

The WB/WS scope appears to be dependent on the previous Find/Replace
i.e. if I did a WB replace, the next VBA Find/Replace will also be for the entire WB.

How do I change and control the scope?


Thanks,
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
Put this before your replace code
Code:
   Range("A1").Find ("@@@")
 
Upvote 0
Wow; unbelievably simple.

I wasted a lot of time trying to find some re: 'Within:='
You ARE the man!

Muchos gracias!
 
Upvote 0
You're welcome & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,224,820
Messages
6,181,154
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top