A Simple 'Find' Problem

morrisgr

Board Regular
Joined
Dec 17, 2005
Messages
62
Hi.
I have a list of 30 Membership numbers on Sheet1, Column A.
I need a Macro to check each number individually to see if it occurs on Sheet 2 in Column A.
The answer needed is a simple 'found'=yes............or no

All the 'Find questions here are far more difficult to follow because of their detailed requirements.

Greatly appreciate any help.
Many thanks from sunny Spain.
Morris
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
Try

Code:
Sub test()
Dim LR As Long, i As Long
With Sheets("Sheet1")
    LR = .Range("A" & Rows.Count).End(xlUp).Row
    For i = 1 To LR
        With .Range("A" & i)
            .Offset(, 1).Value = IIf(IsNumeric(Application.Match(.Value, Sheets("sheet2").Columns("A"), 0)), "Yes", "No")
        End With
    Next i
End With
End Sub
 
Upvote 0
Wow, 7 minutes to get a reply. Fantastic.
A little more help if you can.
It works of course but puts "yes" in Column B on Sheet1.

What I need is that it will use variable (found) that will determine whether I copy the Member's info from Sheet1 to Sheet2.

Something like.....
If found="Yes" then Range("A2").Copy
Sheets("Sheet2").Activate
then Paste the info to the next free row (which I know how to do)

Many thanks.....
Morris
 
Upvote 0
Try

Code:
Sub test()
Dim LR As Long, i As Long
With Sheets("Sheet1")
    LR = .Range("A" & Rows.Count).End(xlUp).Row
    For i = 1 To LR
        With .Range("A" & i)
            If IsNumeric(Application.Match(.Value, Sheets("sheet2").Columns("A"), 0)) Then .Copy Destination:=Sheets("Sheet2").Range("A" & Rows.Count).End(xlUp).Offset(1)
        End With
    Next i
End With
End Sub
 
Upvote 0
Hi Peter.
My apologies.
I realise that my wording wasn't quite accurate.
My Sheet1 has a list of ALL members.
My Sheet2 only has some of them.
If I select a Member's number from Sheet1, I want to chjeck if it is already on Sheet2, and if so.......don't paste it.
It should only paste if the Member is NOT on Sheet2.

Sorry, my fault.

Interesting that you use your co-ordinates in your profile.
Thanks for taking the trouble.
Morris
ps.....is it possible to give me a variable rather than simply pasting it in automatically? I can use that procedure elsewhere.
 
Upvote 0
Try this

Code:
Sub test()
Dim LR As Long, i As Long, Found As Boolean
With Sheets("Sheet1")
    LR = .Range("A" & Rows.Count).End(xlUp).Row
    For i = 1 To LR
        With .Range("A" & i)
            Found = IsNumeric(Application.Match(.Value, Sheets("sheet2").Columns("A"), 0))
            If Not Found Then .Copy Destination:=Sheets("Sheet2").Range("A" & Rows.Count).End(xlUp).Offset(1)
        End With
    Next i
End With
End Sub
 
Upvote 0
Excellent.
That's working perfectly.
Many thanks............until next time no doubt.
Regards
Morris
 
Upvote 0

Forum statistics

Threads
1,224,503
Messages
6,179,134
Members
452,890
Latest member
Nikhil Ramesh

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