Getting things to happen in particular months

Red over White

Board Regular
Joined
Jul 16, 2011
Messages
123
Office Version
  1. 365
Platform
  1. MacOS
I am trying to write a VBA program where actions are dependent on what the current month is. In the example below, in February, May, August or November one set of actions will happen and in the remaining months another set of actions will occur.
If the macro was run today, I would be looking for the program to be picking up on the “=11” element.
What I’m struggling what is what the correct TODAY/MONTH combination for this to happen, bearing in mind I use UK date formats. I have tried various combinations of TODAY, MONTH and DATE, with and without brackets, but have not had any success

If TODAY/MONTH combination = 2 Or 5 Or 8 Or 11 Then
One set of actions
End if
If TODAY/MONTH combination <> 2 Or 5 Or 8 Or 11 Then
Another set of actions
End if

If someone does come up with a solution, I would be grateful if they could clarify if I need to put leading zeroes in front of the single digit months in readiness for next year.

Thanks
 
clear.

please rename my macro from month() as thats not helping. Call it test() or something ?
 
Upvote 0

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
you cant have a macro called month() as thats reserved for VBA commands ..
 
Upvote 0
Solution
clear.

Can I ask, in your macros somewhere, have you tried to create one called "month()" .. I ask as I see you have a "month1()".... and I'm wondering if its getting confused.

or maybe you made a UDF script somewhere called Month()

you cant have a macro called month() as thats reserved for VBA commands ..
That's it, it works when I change the name of the macros. The underlying script is fine. Thanks for you help.
 
Upvote 0

Forum statistics

Threads
1,215,129
Messages
6,123,217
Members
449,091
Latest member
jeremy_bp001

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