|
-
Jul 14th, 2009, 02:53 PM
#1
Thread Starter
Member
[RESOLVED] VB Find and Replace Loop
Hi. I just started a job that seems to focus on editing code in VB. I have no idea why I am doing it. I seem to run into a lot of issues. Anyway, here is my current problem that I was hoping one of you would not mind answering.
I have a Workbook with 2 Tabs - Everything and Test Page. On the Everything Tab I have a list of phone numbers in Column L and on Test Page I have the results of Filtering out which phone numbers are duplicates.
What I want to do is find them on the Everything Page and Replace them with "Duplicate." Now I have done the Macro and it looks like below:
Sub DupeA()
'
' DupeA Macro
' Remove Dupes
'
'
Range("A3").Select
ActiveCell.FormulaR1C1 = "9546259428"
Selection.Replace What:="9546259428", Replacement:="05-MM-Dupe", LookAt:= _
xlPart, SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Range("A4").Select
ActiveCell.FormulaR1C1 = "5615422286"
Selection.Replace What:="5615422286", Replacement:="05-MM-Dupe", LookAt:= _
xlPart, SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Range("A5").Select
ActiveCell.FormulaR1C1 = "7863954078"
Selection.Replace What:="7863954078", Replacement:="05-MM-Dupe", LookAt:= _
xlPart, SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
End Sub
As you can see it will only replace the 3 Ranges that I have selected. I was hoping to create a loop that would do the same thing as above but not be so specific.
My end goal is to be able to press one button and have it replace all the duplicates on the Everything page. However, say the next set of Duplicates are from A3:A25 on the Test Page. I need the loop to be able to adjust.
I have no idea how to do this though. I was looking around on GOOGLE and I came up with just about nothing that I could understand.
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
|
Click Here to Expand Forum to Full Width
|