so I wrote this code that's supposed to result in an two arrays that should start from cells I4 and O4, respectively.
Option Explicit
Sub QuartTransfer()
Dim wb As Workbook: Set wb = ThisWorkbook ' workbook containing this code
Dim cws As Worksheet: Set cws = wb.Worksheets("All Transaction Data")
Dim dws As Worksheet: Set dws = wb.Worksheets("Quarterly Transfers")
Dim srg As Range: Set srg = cws.Range("B2:V" & dws.Range("C1").Value)
Dim Data As Variant: Data = srg.Value
Dim Sale(), Pur() As Variant
Application.ScreenUpdating = False
Dim i, k, p As Long
For i = 1 To UBound(Data, 1)
If Data(i, 9) = "Intra L.E. Sale" Or Data(i, 9) = "Tax Free Exchange - Dis" Or Data(i, 9) = "InterCompany Sale IP2" Then
k = k + 1
ReDim Preserve Sale(6, 1 To k)
Sale(1, k) = Data(i, 5)
Sale(3, k) = Data(i, 1)
Sale(4, k) = Data(i, 11)
Sale(5, k) = Data(i, 13)
Sale(6, k) = Data(i, 8)
ElseIf Data(i, 9) = "Intra L.E. Purchase" Or Data(i, 9) = "Tax Free Exchange - Acq" Or Data(i, 9) = "InterCompany Pur IP2" Then
p = p + 1
ReDim Preserve Pur(7, 1 To p)
Pur(1, p) = Data(i, 9)
Pur(2, p) = Data(i, 5)
Pur(4, p) = Data(i, 1)
Pur(5, p) = Data(i, 11)
Pur(6, p) = Data(i, 13)
Pur(7, p) = Data(i, 8)
End If
Next i
dws.Range("I4").Resize(k, 6).Value = Application.WorksheetFunction.Transpose(Sale)
dws.Range("O4").Resize(p, 7).Value = Application.WorksheetFunction.Transpose(Pur)
Application.ScreenUpdating = True
End Sub
The problem is that the results are shifted one column to the right with the last column of data missing. Is there something I'm missing here? Pls help!