matching dates with VBA

awsumchillicrab

Board Regular
Joined
Jan 30, 2011
Messages
56
I will be using a today() formula in a cell (say A100), and pasting values only.
I then have row A showing years, and row B showing months. A1 to L1 is 2011, B1 to L1 is Jan - Dec. M1 to X1 is 2012, M2 to X2 is Jan - Dec...etc.

I want my code to know which column I want to work on based on the today() date. And as there are so many options, I would prefer something better than IF-THEN-ELSEIF, or the IF-CASE system where I have to explicitly give 50 parameters if I have 50 columns.

Was hoping to do something like a month(A100) and year(A100), find the correct column, and then declare that as x in VBA, so that my code can use:

range(x & "3")

in order to select, say B2 for Feb 2011.

Any help?
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
in order for exel to compare today for cells with months only, that cell must be a "real" date. So if you want only the month in a cell, then format the date as "MMMM"
 
Upvote 0

Forum statistics

Threads
1,224,602
Messages
6,179,843
Members
452,948
Latest member
UsmanAli786

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