Hello
I am writing a code to write this code to populate an array based on an If statement and then unload that array into a range.
Here is a sample of my code
For some reason this code returns blanks... it appears to be blank when I debug.print to immediate window and I'm not sure what I'm doing wrong.
I did however get it to work once by fluke, but the code took forever to work.. if you could help factor in a faster version of this for me to work off of, I would appreciate it!!
I am writing a code to write this code to populate an array based on an If statement and then unload that array into a range.
Here is a sample of my code
VBA Code:
Sub UpdateFromPCT()
Dim wkb As Workbook
Dim ws As Worksheet
Dim pct As Workbook
Dim pctST As Worksheet
Dim i As Long
Dim holdAry() As Variant
Dim Count As Integer
Count = 0
Set wkb = ThisWorkbook
Set ws = wkb.Worksheets(1)
Set pct = Workbooks.Open("C:\Users\user\OneDrive - Enagic USA Inc\General\Payment Check Tool.xlsm")
Set pctST = pct.Worksheets("Batch Processing & Hold List")
With pctST
lastRow = .Range("C6").End(xlDown).Row
For i = 6 To lastRow
ReDim holdAry(1 To lastRow + 5) As Variant
If .Range("K" & i).Value = "Tokurei" Or .Range("K" & i).Value = "OK" Then
Else
Count = Count + 1
holdAry(Count) = .Range("C" & i).Value
End If
Next i
End With
With ws.Range("N2:N700")
For i = LBound(holdAry) To UBound(holdAry)
.Range("N" & i).Value = holdAry(i)
Next i
End With
End Sub
For some reason this code returns blanks... it appears to be blank when I debug.print to immediate window and I'm not sure what I'm doing wrong.
I did however get it to work once by fluke, but the code took forever to work.. if you could help factor in a faster version of this for me to work off of, I would appreciate it!!