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

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
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.
 
Upvote 0
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.
 
Upvote 0

Forum statistics

Threads
1,214,832
Messages
6,121,845
Members
449,051
Latest member
excelquestion515

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