Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Macro help to resolve search a worksheet for match in another

Status
Not open for further replies.

andycapp28

Technical User
Mar 2, 2010
86
GB
I have this code but cannot get it to run into my loop.
Any help would be most welcome.

Requirement is to read all column C in worksheet1 and for each cell check its value for existence in worksheet2. If found then I need to copy the value from worksheet2 activecell -1 into activecell -1 of worksheet1.

Code:
Sub GetImportID()
    
 Dim rLookfor
 Dim rLookin
    
    Set rLookfor = Worksheets("Sheet1").Range("B1").End(xlDown)
    Set rLookin = Worksheets("Sheet2").Range("C1").End(xlDown)
    
Do Until ActiveCell.Value = ""
    
    For Each c In rLookfor.Cells
        
        f = rLookin.Find(c.Value)
        
        If ActiveCell.Value = f Then
        
        rLookin(ActiveCell, ActiveCell.Offset(0, -1)).Copy
        
        rLookfor(ActiveCell, ActiveCell.Offset(0, -1)).Paste

        End If
    Next
    
        rLookfor(ActiveCell, ActiveCell.Offset(1, 0)).Select
    
Loop
    
End Sub
 
I added expression rLookin to the watch window

I was looking for something called address in the window clearly I am wrong.

I will read the help again
 



Just EDIT that expression and append .address

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 



but sheet1 range B1:B570 is the rLookfor range, isn't it?

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 


Hmmmm?

I set up a test in a workbook and it worked perfactly it seems.

Where is your CODE located?

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 



Try removing the

Dim xlWhole as boolean

since xlWhole is a VBA CONSTANT.

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
sorry skip, its been a long day

I have already posted my code so I don't understand what you mean by where is my code located
 
Amazing.

I don't understand I tried that before I added the latest postings.

Anyhow for now many thanks skip

I will retest tomorrow but looks great.
 
I meant, where is your codelocated IN YOUR WORKBOOK?

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Its in the hidden personal.xls

xlwhole appears to have fixed my users error that was occurring.

Sorry for troubling you with what simply wouldn't work before I raised the thread.

I shall retest in live next business day.

many thanks skip
[2thumbsup]
AC

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top