Static Arrays

Bridgford

New Member
Joined
Oct 23, 2008
Messages
28
Hi,

I am trying to create some statistical functions as an Excel add-in. These functions need to reference values from statistical tables. I would much rather put these tables into the vba code as static arrays, but I am stumped as to how to accomplish this. The statistical tables would be two dimensional arrays and would be static.

How does vba want the values in a two dimensional array entered? Specifically, the first of the tables is 26 rows by 50 columns. When dimensioning the array, does vba expect rows, then columns, or vice versa?

Assuming I am successful in this portion, I will have questions on how to pull specific values from the array analogous to vlookup or hlookup, if anyone wants to expound on those.

Any insight is greatly appreciated.

Thanks,

Dale
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
What kind of add-in? xla or dll?
If it's an xla you could simply store them on a worksheet.
 
Upvote 0
Thanks for your replies. I was intending to create an xla add-in, but I would prefer to not have anything on a worksheet.

Thanks,

Dale
 
Upvote 0
Ultimately, I don't know who will end up using it and I would rather not leave the tables exposed in the workbook. Perhaps it is shortsighted, but that is where my thinking is.

Since it has started to be kind of obscure, it is becoming a matter of principal and now I want to understand how two dimensional static arrays work in vba. Discussions I have found tend to be basic, and the one reference I found, I lost the page and can't relocate it.

In short, I'm sort of stubborn.

Thanks,

Dale
 
Last edited:
Upvote 0
Each to their own, but since the user can't see the sheets, it seems odd. ;)

You also cannot declare a constant array of any sort in VBA. You would have to declare a variable and then populate it in a loop, hence my suggestion of a worksheet as it allows you to read all the values in in one go.
 
Upvote 0
First, thanks to you both, as you each have weighed in on several occasions with useful advice.

I was unaware that the sheet would be unseen. That is different. Going the worksheet route, would it be more efficient to do the vlookup/hlookup worksheet function or read the table in as a range?

Do I have to do anything special to the sheet so that it doesn't show up?

Thanks again,

Dale
 
Upvote 0
For a table that small, I doubt you'd see any difference either way. I would probably read from the range.
When you save the workbook as an add-in, it will automatically become hidden (and cannot be unhidden without altering the IsAddin property)
 
Upvote 0
You will only be able to access the worksheet while the workbook is an xls. It will be hidden when the workbook is saved as an xla. I would name the range (Insert|Name|Define) and use the INDEX and MATCH worksheetfunctions in VBA.
 
Upvote 0

Forum statistics

Threads
1,214,406
Messages
6,119,330
Members
448,888
Latest member
Arle8907

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