Vba for exisiting values from different sheets

crims0n

New Member
Joined
Aug 18, 2011
Messages
12
I would like to create a vba code/macro. when the button is click. If will check the value of column A or what ever column you choose from sheet 2, then check if those values are present in column A from sheet 1. If that value is not present in sheet 1, it will prompt that that value is not existing.

Somehow. It will be checking multiple columns in 1 sheet and check those values that is located in another sheet.

Would like to know the best approach for this. Thanks
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
Something like this?:
Code:
Sub test()
For i = 1 To Sheets.Count 'check number sheets
n = Sheets(i).Cells(Rows.Count, "A").End(xlUp).Row 'check lenght column
For r = 1 To n 'scan cells in column
If Sheets(i).Cells(r, "A") = [COLOR=Red]Sheets(1).Range("E1")[/COLOR] Then 'match with referring value (set your range value)
memo = memo & Sheets(i).Name & "!" & Cells(r, "A").Address & ", "
End If
Next
Next
MsgBox ("The value is in position: " & Left(memo, Len(memo) - 2) & ".")
End Sub
 
Last edited:
Upvote 0
forget to mention. 1 sheet(sheet1) will contain a distinct and fix set of values. the other sheet(sheet2), the column will only accept values that are found in the column from sheet1. It will still try to match. sorry for the confusion.
Thanks I also got an idea from your code.
 
Upvote 0

Forum statistics

Threads
1,224,598
Messages
6,179,818
Members
452,946
Latest member
JoseDavid

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