Declaring Constant Arrays?

Status
Not open for further replies.

HedgePig

Board Regular
Joined
Jun 27, 2002
Messages
146
Hello

Can I declare a "constant array" in VBA?
What I would like to do is set up a constant which contains the number of days in each month (ignoring leap years), e.g.

Const DaysInMonth(12) as Integer = Array(0,31,28,31,30,31,30,31,31,30,31,30,31)

However, I'm unable to find the correct syntax. Is this possible in VBA? (I'm using Excel 97)

Regards
Hedges
 
You know what is absolutely amazing? No one -- not one of you -- provided Kelly with a solution. Maybe, you meant to, but you didn't. I was the first to point out that a function can simulate a constant array.

In addition to using a function, one can also implement a constant array with a read-only property or a write-once property in a class module.

Yet, none of you provided him with any of those possible solutions. Nor did anyone research the subject and come up with a way to implement a constant array.

So, don't get all high-and-mighty about wanting to discuss the topic of interest. None of you has done that! And, the topic of interest is *constant arrays* not arrays in general.
Von Pookie, it had been laid to rest until Tushar resurrected it. He did not just discuss the subject at hand: arrays, but couldn't understand peoples reactions to OP2, and said so quite strongly.
 
Upvote 0

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
Status
Not open for further replies.

Forum statistics

Threads
1,214,534
Messages
6,120,086
Members
448,944
Latest member
sharmarick

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