Use the following modified code. It's assumed that the second row's headers are present:
Sub AutoFilter_on_visible_data()
Dim ws As Worksheet, arr, i As Long, lastR As Long, lastCol As Long, arrH, rngH As Range, rng As Range
Const helpH As String = "HelpColumn"
Set ws = ThisWorkbook.ActiveSheet
lastR = ws.Range("A" & ws.rows.count).End(xlUp).row
lastCol = ws.cells(2, ws.Columns.count).End(xlToLeft).column 'last column, supposing that the header exists on the second row
Set rngH = ws.rows(2).Find(what:=helpH, LookIn:=xlValues, Lookat:=xlWhole)
If Not rngH Is Nothing Then 'if the helper header exists:
lastCol = rngH.column
Else 'if not it is defined:
lastCol = lastCol + 1
ws.cells(2, lastCol).Value = helpH
End If
Set rng = ws.Range(ws.cells(2, 1), ws.cells(lastR, lastCol)) 'to use it for filterring
If Not ws.AutoFilterMode Then rng.AutoFilter 'autofilter the resized range
ws.AutoFilter.ShowAllData
arr = ws.Range("A3:R" & lastR).Value2 'Place the relevant columns in an array for faster iteration
ReDim arrH(1 To UBound(arr), 1 To 1)
For i = 1 To UBound(arr)
If ws.rows(i + 2).Hidden = False Then '(i + 2) because Data starts at Row_3
If Not arr(i, 2) Like "*Oil*" And _
Not arr(i, 5) Like "*-SYS-14" And _
Not arr(i, 6) Like "*Oil" Then
arrH(i, 1) = "HH" 'Make a helper array to filter on it.
End If
End If
Next i
'Drop the arrH content at once:
ws.cells(3, lastCol).Resize(UBound(arrH), 1).Value2 = arrH
'Filter on the helper column:
rng.AutoFilter field:=lastCol, Criteria1:="HH", Operator:=xlFilterValues
End Sub