Hi guys
Im using a dynamic array to scan through a range and pull out information but the array dosnt seem to be working as an array because i only gets the last value it finds.
Im using a dynamic array to scan through a range and pull out information but the array dosnt seem to be working as an array because i only gets the last value it finds.
VBA Code:
Sub ExportToInvoice2()
Dim wRange As Range
Dim cell As Range
Dim myArray() As Variant
Dim i As Long
Sheets("Frame Variables").Select
Set wRange = Range("AQ10:AQ416")
For Each cell In wRange
ReDim Preserve myArray(i)
x = cell
x = Mid(cell, 1, 1)
If x = "U" Then
myArray(i) = cell.Value
MsgBox myArray(i)
End If
Next cell
For a = LBound(myArray) To UBound(myArray)
'Debug.Print myArray
lr = ThisWorkbook.Sheets("sheet1").Cells(Rows.Count, 1).End(xlUp).Row
Sheets("Sheet1").Cells(lr + 1, 1) = myArray
Next a
End Sub
Last edited by a moderator: