I am working with a long list in excel and I have to select specific rows that fit criteria. I managed to create an array containing the index number of those rows. All I have to do now is to select those rows.
Here's the code:
Sub Playground()
Dim currentContract As String
currentContract = "none"
Dim CCIsPos As Boolean
CCIsPos = False
Dim asarray() As Integer
Dim i As Integer
ReDim asarray(1 To Sheets("Playground").UsedRange.Rows.Count)
For Each Cell In Sheets("Playground").Range("E:E")
matchRow = Cell.Row
If Cell.Value <> currentContract Then
currentContract = Cell.Value
If Cells(matchRow, "J") > 0 Then
CCIsPos = True
Else
CCIsPos = False
End If
End If
If CCIsPos Then
i = i + 1
asarray(i) = matchRow
End If
Next Cell
'Would need a function here selecting rows from the array "asarray"
'Rows(asarray).Select doesn't work.
End Sub
range("a1, a4, a6").Entirerow.SelectIntegertype is a problem. It is recommended to replace all instances ofIntegerwithLongwhich is a 32-bit integer value. TheIntegertype is 16-bit wide only. (see stackoverflow.com/a/31816532/380384)