Sub FilterData()
'Declare variables
Dim ws As Worksheet
Dim rng As Range
Dim lastRow As Long
Dim i As Long
Dim j As Long
'Set ws variable to the worksheet you want to filter
Set ws = ThisWorkbook.Sheets("Sheet1")
'Find last row of data in column A
lastRow = ws.Cells(ws.Rows.Count, "A").End(xlUp).Row
'Create new worksheet for filtered data
ThisWorkbook.Sheets.Add(After:=ThisWorkbook.Sheets(ThisWorkbook.Sheets.Count)).Name
= "FilterData"
'Copy header to new sheet
ws.Range("A1:G1").Copy ThisWorkbook.Sheets("FilterData").Range("A1")
'Loop through each row
For i = 2 To lastRow
'Check if value in column A is between 371028 and 371199 or between 381054 and
381199 or between 481021 and 481199
If ws.Cells(i, "A").Value >= 371028 And ws.Cells(i, "A").Value <= 371199 Or
ws.Cells(i, "A").Value >= 381054 And ws.Cells(i, "A").Value <= 381199 Or
ws.Cells(i, "A").Value >= 481021 And ws.Cells(i, "A").Value <= 481199 Then
'If the criteria is met, copy the entire row to the new sheet
ws.Rows(i).Copy ThisWorkbook.Sheets("FilterData").Rows(j + 2)
j = j + 1
End If
Next i
'Delete all blank rows in the new sheet
With ThisWorkbook.Sheets("FilterData")
lastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
For i = lastRow To 2 Step -1
If Application.CountA(.Rows(i)) = 0 Then
.Rows(i).Delete
End If
Next i
End With
'Autofit rows in the new sheet
ThisWorkbook.Sheets("FilterData").Columns.AutoFit
End Sub