LookingforGuidance
New Member
- Joined
- Aug 3, 2011
- Messages
- 10
Hello all,
I am looking for a bit of help with the .Find function. I am trying to automate the process of checking for multiple duplicates but am getting stuck in 3 places that I am aware of at this point:
1. How do I tell my .Find to search within a specific column? Say, column B
- I know that I can pre-select my range with the following, but would like to do it within the .Find or with a variable if possible:
2. If I've found a match, how do I tell the search to find the next match in column B? I think I use an If statement and compare the results, but I don't want to loop around the bottom and start again from the top.
3. If I have reached the end of column B (matches or not), how do I stop without looping again back to the first match? This would fit into the Else If above. What I've used before is to check for the error message that a no-hit gives, but this seems to only work when looking for 1 duplicate and not multiple duplicates.
Again, I am just trying to process cells down column A against all of column B and if a duplicate is found, copy it to tab 2.
If anyone has any ideas but needs more information, I'd be glad to provide whatever I can.
Thank you,
LFG
I am looking for a bit of help with the .Find function. I am trying to automate the process of checking for multiple duplicates but am getting stuck in 3 places that I am aware of at this point:
1. How do I tell my .Find to search within a specific column? Say, column B
- I know that I can pre-select my range with the following, but would like to do it within the .Find or with a variable if possible:
Code:
Workbooks(WorkbookToUse).Worksheets(MainWorksheet).Columns("B").Select
Code:
SearchAgain:
Cells.Find(What:=DataToFind, after:=ActiveCell, LookIn:=xlValues, _ LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, _ MatchCase:=False, SearchFormat:=False).Select
If ActiveCell.Value = DatatoFind then
'Send Results to Tab 2
'Search again
GoTo SearchAgain
Else if DataToFind = Null or End of Column reached then
'go to the next row in column A
End If
Again, I am just trying to process cells down column A against all of column B and if a duplicate is found, copy it to tab 2.
If anyone has any ideas but needs more information, I'd be glad to provide whatever I can.
Thank you,
LFG