2 Dimensional Array VBA

Steve001

Board Regular
Joined
Apr 13, 2017
Messages
62
Office Version
  1. 365
  2. 2021
  3. 2013
Platform
  1. Windows
Hi,

struggling a bit if someone can help me out please.
I want to create an array with two strings "partno" , "description"
I can create a 1 string array but i haven't got a clue :confused:. with two strings

Can you please put comments in the code - still finding my way about with VBA

my string (1) "partnumber", "description"

I want to read the array and come up with the answer bellow

stringa = "partnumber"
stringb =" description"

Hope this makes sense what I am trying to do

Steve
 
Last edited:

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.
It's not really clear to me why you can't simply add another item to your arrayL

Code:
mystring(1) = "partnumber"
myString(2) = "description"

If you need a 2D array, you would use:

Code:
mystring(1, 1) = "partnumber"
myString(1, 2) = "description"
 
Upvote 0
Hi Roy,

sorry might not have made my self clear I would like to read down an array table then from an entry be able to get two strings one for a part number another for the description.
or would two arrays be simpler ? one for each ?

Steve
 
Upvote 0
I'd probably just use one delimited string, which you can then parse using Split:

Rich (BB code):
mystring(1) = "partnumber|description"

then you can use:

Rich (BB code):
Stringa = Split(mystring(1), "|")(0)
Stringb = Split(mystring(1), "|")(1)

for example.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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