I have code with a multi dimensional array. The code searches for lines that have a certain number in a certain cell. When the array is pasted in a new worksheet, empty lines of data are kept. Is there a way for the array to skip rows that don't meet my if statement?
Sub LM_Data()
Dim arrLM()
Dim intRows
Dim intCols
Dim s As Integer
intRows = Cells(Rows.Count, 1).End(xlUp).Row
intCols = 13
For s = 0 To 5
ReDim arrLM(1 To intRows, 1 To intCols)
For i = 1 To UBound(arrLM, 1)
If Cells(i, 4).Value = CStr(s) And Cells(i, 3).Value <> "0" Then
For j = 1 To UBound(arrLM, 2)
arrLM(i, j) = ActiveSheet.Cells(i, j)
Next j
End If
Next i
Sheets(CStr(s)).Range("a1", "m" & intRows).Value = arrLM
Next s
End Sub
Bookmarks