Hi all,
I have a workbook that downloads information from the internet and places it on a spreadsheet. That part works fine, but I am also trying to include a filter in the process. I am using a string variable (that may not be the correct term), that is used in the url and also is the name of the sheet where the filtered data is supposed to end up. Abbreviated code as follows (i did not include the query part of the code):

Sub GetData()

Dim strFin(1 To 3) As String
    strFin(1) = "basicmaterials"
    strFin(2) = "consumergoods"
    strFin(3) = "financial"

For Z = 1 To 3

Dim RowCt As Integer
Dim RowTot As Variant

Sheets("Raw").Activate
RowTot = ActiveSheet.UsedRange.Rows.Count

For RowCt = 2 To RowTot
        If (Sheets("Raw").Cells(RowCt, 7).Value < 0 And Sheets("Raw").Cells(RowCt, 5).Value > 0 And _
            Sheets("Raw").Cells(RowCt, 4).Value > 0) Then
                Range("A" & RowCt & ":" & "K" & RowCt).Select
        Selection.Copy Destination:=Sheets(strFin(Z)).Range("A" & Rows.Count).End(xlUp).Offset(1, 0)
    End If
Next RowCt

Next Z

End Sub
I am getting a Run-time error '9' Subscript out of range in the red line of code.

This worked when I tested it with a specific sheet name (e.g. "basicmaterials"), but it doesn't this way.

Thanks.