0

I am getting the runtime error '1004' when trying to assign values to PatternList array in the second iteration of for i=0 to j-1 loop (when i equals 1). Please note that, I am not getting any error in the first iteration of for i=0 to j-1.

I am attaching snapshots from the two sheets that I am referring to in the code (Batch Run and gridding sheets)

What am I missing? I have been stuck at this problem for hours now. I would highly appreciate any help!

Sub BatchRun_v2_draft()
Dim PatternList As Variant

Sheets("Batch Run").Select
j = Range("B1").Value
For i = 0 To j - 1
    ReDim PatternList(0, 3)
    PatternList = Worksheets("Batch Run").Range(Cells(i + 4, 11), Cells(i + 4, 14))
    'Getting application-defined or object-defined error 1004 executing above line

    Dim row_st, cl_st, counter As Long
    Dim rowCount, rowCount2 As Long
    Dim PanelG As New Collection
    Dim params As Variant
    ReDim params(100, 1)

    PanelG.Add Array(2, 4)
    PanelG.Add Array(2, 7)

    Sheets("gridding").Select
    counter = 0
    counter2 = 1
    For row_st = 0 To 1
        For cl_st = PanelG(counter2)(0) To PanelG(counter2)(1)
            Range("BG3").Offset(row_st, cl_st).Select
            If Not IsEmpty(ActiveCell) Then
                params(counter, 0) = Worksheets("gridding").Range("BG3").Offset(row_st, cl_st + 95).Value
                counter = counter + 1
            End If
        Next cl_st
        counter2 = counter2 + 1
    Next row_st
    Worksheets("OP_Platform").Range("AP11:AS" & counter + 10).Value = params
    Erase params
    Erase PatternList
Next i

End Sub

Batch Run Sheet gridding

BigBen
  • 38,994
  • 6
  • 24
  • 37
Feminist
  • 75
  • 8

0 Answers0