Adjust listbox for the number of days in the month

brianfosterblack

Active Member
Joined
Nov 1, 2011
Messages
251
I have sheets for a Financial year Mar to Feb - So Jan and Feb obviously fall in the next year. The year for the start of the financial year is in cell "Master!$C$2"
I run the same macro from any of these sheets.
The macro opens up a userform in which listbox5 has the days of the month from 1 to 31 to select the day in that months under which data must be entered.
I need that if I am running this macro when in Feb month it does not allow anything above 28 to be selected and 29 in a leap year and in a month like April I cannot select 31
If these are selected it will cause an error when the macro tries to insert the data under a column which does not exist in the worksheet for that month.
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
I have sheets for a Financial year Mar to Feb - So Jan and Feb obviously fall in the next year. The year for the start of the financial year is in cell "Master!$C$2"
I run the same macro from any of these sheets.
The macro opens up a userform in which listbox5 has the days of the month from 1 to 31 to select the day in that months under which data must be entered.
I need that if I am running this macro when in Feb month it does not allow anything above 28 to be selected and 29 in a leap year and in a month like April I cannot select 31
If these are selected it will cause an error when the macro tries to insert the data under a column which does not exist in the worksheet for that month.
I forgot to mention that Listbox 5 is poulated from a range named "DayList" which is in range "Master!AP2:AP32"
 
Upvote 0

Forum statistics

Threads
1,215,771
Messages
6,126,799
Members
449,337
Latest member
BBV123

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