-
Solved: Find & Replace Macro replacing outside of defined area
I have recorded the following macro to replace the letter L & W in the defined columns and rows, but it is also replacing the letter L & W in column A, how can I stop it from replacing outside the defined columns and rows in the macro.
Thanks
[VBA]Private Sub CommandButton1_Click()
Range("$B$1:$G$28").Select
Cells.Replace What:="W", Replacement:="", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Range("$B$1:$G$28").Select
Cells.Replace What:="L", Replacement:="", LookAt:=xlWhole, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
End Sub
[/VBA]
-
Instead of Cells.Replace, it should be Selection.Replace
-
Thanks, JKwan thats has solved that problem, I will mark as solved, thanks again.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules