Adding data from one Array into another in excel VBA

fabdullaster

New Member
Joined
Feb 24, 2012
Messages
9
Hello, I am trying to find a way to copy a Array1() of 124 different items every loop cycle into Array2(). So Array2() will contain Array1() content for each cycle. I read about Redim, but I have no idea how to use it. Thanks
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
Here is the code I have so far.
Code:
Dim i As Integer 
Dim Array1() As String 
Dim Array2() As String 
Dim IngRows As Long 
Sheets("SimGen").Select 
IngRows = ActiveWorkbook.ActiveSheet.Range("B37").End(xlDown).Row 
 
If IngRows > 52 Then 
    IngRows = 37 
End If 
 
 ' Subtract out the distance from B9 to B1, This section will give me the row that the user has entered. So i may vary between one cycle to 16 cycles.
IngRows = IngRows - 37 
For i = 37 To IngRows + 37 
     
    AnalogTag = Worksheets("SimGen").Range("B" & i).Value 
    For SingleIndex = 0 To 124 
        Redim Preserve Array1(SingleIndex) 
        Sheets("CTXArray").Select 
        Array1(SingleIndex) = Worksheets("CTXArray").Range("C" & SingleIndex + 1).Value 
    Next SingleIndex 
     
    Array1(6) = Replace(Array1(6), "Data_Sim", AnalogTag) 
    Array1(11) = Replace(Array1(11), "data_sim", AnalogTag) 
     
     'This is where I tried to resize array2 and move data from array1, but I think it is wrong.
     'This what I am trying to accomplish is Array1 will always change 'content each loop cycle
     'and i want to move it content into Array2 and keep adding into Array2 as the loop cycles. maybe there is another way of doing this.
    Redim Preserve Array2(UBound(Array2) + UBound(Array1)) 
    Array2 = Array1 
     
     
Next i
 
Upvote 0

Forum statistics

Threads
1,214,979
Messages
6,122,557
Members
449,088
Latest member
davidcom

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