Array populating problem

2016LM

New Member
Joined
Sep 9, 2016
Messages
18
Hi,

I’m hoping someone can help me, I have looked online but to no avail.

I understand there is a quick way to populate an array in VBA, with values taken from a worksheet e.g.


2DArray= worksheets(“Sheet1”).range(“A1:A4”).value


The above populates a 1(column) x 4(elements) array (named 2DArray) with values taken from the worksheet in column A1 to A4.


My question, is it possible to populate 2DArray with another [worksheet] column of data (e.g. residing in cells C1 to C4) using the same command, but without having an empty column in 2DArray e.g.


2DArray= worksheets(“Sheet1”).range(“A1:A4” & “C1:C4”).value


Any help / assistance anyone can provide would be much appreciated.

Kind regards,

2016LM
 
Last edited:

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
Fraid not, the range must be contiguous to use that method.
 
Upvote 0
It's not exactly an array, but you can use Union to achieve something similar with a range

Code:
Sub Test()

    Dim TwoDArray As Range
    
    Set TwoDArray = Union(Range("A1:A4"), Range("C1:C4"))
    
    TwoDArray.Select


End Sub
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,951
Messages
6,181,973
Members
453,079
Latest member
hps1972

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