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
153
Office Version
  1. 365
Platform
  1. Windows
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

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result

Forum statistics

Threads
1,223,214
Messages
6,170,772
Members
452,353
Latest member
strainu

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