DataBlake
Well-known Member
- Joined
- Jan 26, 2015
- Messages
- 781
- Office Version
- 2016
- Platform
- Windows
I'm trying to write a row to the end of an array
the logic is essentially:
i = loop through UBound of array 1
x = loop through UBound of array 2
if statement is true then
add the entire row we are looping through from array 1 to the bottom of the array
make changes to the new line and add 4 new values the columns of the row
so what i have so far looks like
highlighted in red is where i'm stuck
the logic is essentially:
i = loop through UBound of array 1
x = loop through UBound of array 2
if statement is true then
add the entire row we are looping through from array 1 to the bottom of the array
make changes to the new line and add 4 new values the columns of the row
so what i have so far looks like
Code:
Dim ary1 As Variant, ary2 As Variant
Dim ws As Worksheet, os As Worksheet
Dim i As Long, x As Long, j As Long
Dim lastRow As Long
Dim destRow As Long
Set ws = Sheets("CondensedSheets")
Set os = Sheets("Description Helper")
ary1 = ws.Range("A1").CurrentRegion.Value2
ary2 = os.Range("A13").CurrentRegion.Value2
lastRow = ws.Range("A" & Rows.count).End(xlUp).Row
destRow = lastRow + 1
For i = LBound(ary1) To UBound(ary1)
For x = LBound(ary2) To UBound(ary2)
If ary1(i, 2) = ary2(x, 15) Then
If (ary1(i, 10) = ary2(x, 8) _
Or ary1(i, 11) = ary2(x, 8)) _
And ary1(i, 8) >= ary2(x, 2) _
And ary1(i, 8) <= ary2(x, 3) _
And j < 5 Then
j = j + 1
'increment row
destRow = destRow + 1
ReDim ary1(1 To destRow, 1 To (UBound(ary1, 2) + 4))
'write the new row in the array
[COLOR=#ff0000][B]ary1(desRow, ???) = ary1(???) [/B][/COLOR]
highlighted in red is where i'm stuck