VBA code for matching cells from a named range to another named range (dates) then execute code

wbstadeli

Board Regular
Joined
Mar 11, 2016
Messages
144
Hi,

Im making a time card for our company and need some help with "matching" two date columns together and if there is a match then execute code. I want this as a vba solution, not a formula. How the worksheets works is; When a user clicks on a button, it will populate a new set of dates for the next pay period, and I then (here is where i need the help!) want to have any holiday date automatically enter into a cell (3 columns to the right of the matching pay period date cell) if the date in the pay period matches one of the holiday dates in my list (which is a named range: Holiday_List, the dates are in column 2). The pay period dates I have in 2 named ranges, "Dates_Week1" and "Dates_Week2" (these are both single column ranges).

How would I write this macro to check all cells in named ranges ("Dates_Week1,Dates_Week2") to see if there is a matching/equal date in my named range ("Holiday_List").columns(2), if matching then "matching date cell in named range("Dates_Week1,Dates_Week2").offset(0,3).value = "Yes"?

Let me know if you would need more clarification, and thank you so much for your time!
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,152,125
Messages
5,768,254
Members
425,460
Latest member
Astros1243

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
Top