Here is a solution:
Sub Filter()
Dim rRange As Range
Dim rRangeColumn As Range
Dim rRangeColumnData As Range 'Column without header (first cell)
Dim rFirstCell As Range
Dim rColumnData As Range ' without header
Set rRange = ActiveSheet.UsedRange
For i = rRange.Columns.Count To 1 Step -1
Set rRangeColumn = rRange.Columns(i)
With rRangeColumn
Set rRangeColumnData = Range(Cells(.Row + 1, i), Cells(.Rows.Count + rRange.Row - 1, i))
Set rFirstCell = .Cells(1, 1) ' header
If Application.WorksheetFunction.CountIf(rRangeColumnData, rFirstCell) > 0 Then
rRangeColumn.EntireColumn.Delete
End If
End With
Next i
End Sub
By the way, your initial code contains an error (For...Next, and i is never used):
For i to LastC
FirstRow=ActiveSheet.Range(Cells(4,1),Cells(4,LastC))
Next i
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…