Array

nada

Board Regular
Joined
Jul 4, 2006
Messages
193
Hi! I am trying to create an array that looks like this:
vtFields = Array(Range("B4").Value, Range("R4").Value)
This works fine but I want the array to contain Range("b4").value to eg Range("CC109").value and then it takes ALOT of time to write the array manually. is there any way of doing this without writing every element in the array? Thanks for any help!
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.

Richard Schollar

MrExcel MVP
Joined
Apr 19, 2005
Messages
23,707
Hi

Use a variant variable, and assign the range to it:

Code:
vArray = Range("B4:CC109")

Best regards

Richard
 

nada

Board Regular
Joined
Jul 4, 2006
Messages
193
thanx but i have tried that and it does not work. let me specify what im mean. I have a long list, lets say in column A. I then want to create an array that contains the values of the list in column A. Thus the array needs to have the same dimension as the length of the list. When I try your example the array has 0 dimension and I cannot get anything out of it. thanks for your help but I need some other solution. any help appreciated!
 

Richard Schollar

MrExcel MVP
Joined
Apr 19, 2005
Messages
23,707
Hi

Make sure you have the variable dimensioned as a variant:

Code:
Dim vArray as Variant
vArray = Range("A1:A100") 'assigns all the values in A1:A1000 to a 2 dimensional array with Ubound(vArray,1) of 1000 and Ubound(vArray,2) of 1

Richard
 

Forum statistics

Threads
1,141,720
Messages
5,708,078
Members
421,545
Latest member
TWR

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