Building an Array in VB

dcanham

Active Member
Joined
Jun 7, 2006
Messages
306
Ok, here is a VB question. If you wanted to have an Array of strings the line would be....

aTestArray = Array("item1","item2","item3","item4","item5")

...what I would like to do is build an array on the fly based on variables pulled off of a sheet. How would I do that?? I tried building a string with the quotes and commas embedded and assigning that

sArrayString = sQuote + sItem1 + sQuote + "," + sQuote + sItem2 + sQuote + "," + ..............etc

aTestArray = Array(sArrayString)


....that didn't work...any suggestions?
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
L

Legacy 98055

Guest
What is the range on your worksheet? There are several ways to assign values to arrays.

Please explain what your are trying to do here instead of how you intend on doing it. There may be a better approach.
 

dcanham

Active Member
Joined
Jun 7, 2006
Messages
306
There is a range of calls that will contain product codes (text values). These could or could not have values in them. I step through the cells, test for a value, then add the product code to the array if there is one. I will then use the built array of product codes to summarize sales data in certain ways then display them on a chart as a series. One series for each product code. I'm sure there is another way I could do it, but it seems as if I should be able to load the array in this way.
 

Forum statistics

Threads
1,141,680
Messages
5,707,789
Members
421,527
Latest member
Tamiwsw

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
Top