How do I combine 2 1 dimensional arrays into one, one dimensional arrays?

Radoslaw Poprawski

Active Member
Joined
Jun 19, 2021
Messages
397
Office Version
  1. 365
Platform
  1. Windows
Hi all
VBA Code:
    CP = ArkUstawienia.Range("A2:A" & LastCell)
    Tabele = Application.Transpose(ArkUstawienia.Range("E2:F2"))
I do have 2 Variant arrays
both are one-dimensional

1682674660351.png


and im trying to combine them into 1.
I tried split(Join(CP,",") &","&join(Tabele,","),",")

Getting and error
1682674770938.png


any ideas?
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
Ok, I mean like this:

newArray(1,1) = 1600083 newArray(2,1) = 1600068 newArray(3,1) = 1600198 newArray(4,1) = 1600095 newArray(5,1) = "EKPO.xlsx" newArray(6,1) = "EKKN.xlsx"
 
Upvote 0
wont work,
the first array can have different amount of items in it, while the second always have 2
 
Upvote 0
I am not asking about the amount. I am asking about the structure. What is it going to look like? Like my example above?
 
Upvote 0
Ok I kinda figured it out myself,

the issue was that when assigning values to array from any sheets range it creates 2 dimensional array - like the ones above.
wjhat VBA join function needs is 1 dimensional array
so instead of this:
1682687619782.png


it should be
NewArray(0) = "A"
NewArray(1) = "B"
NewArray(3) = "C"

and I achived it bit wrong (?)

I used
VBA Code:
application.worksheetfunction.textjoin()
to combine the data into one string.
then using VBA split I assigned values to an array getting 1 - dimentional array, however
since I used worksheet function I told it to combine text from all the ranges I wanted skipping the need for VBA JOIN function in the process
 

Attachments

  • 1682687611729.png
    1682687611729.png
    4.8 KB · Views: 0
Upvote 0

Forum statistics

Threads
1,215,235
Messages
6,123,792
Members
449,126
Latest member
Greeshma Ravi

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