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

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
Status
Not open for further replies.

Forum statistics

Threads
1,223,630
Messages
6,173,456
Members
452,514
Latest member
cjkelly15

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