I’m trying to find the first row value of each column. Upon knowing the first value, I want to find whether the column contains the same value as the first row. If yes, I want to delete the entire column.
lastR = ActiveSheet.Cells(Rows.Count,1).Row
LastC = ActiveSheet.Cells(1, Columns.Count).Column
For i to LastC
FirstRow=ActiveSheet.Range(Cells(4,1),Cells(4,LastC))
End i
For x= LastC to 1 Step -1
If Worksheet.Function.CountIf(Columns(x), “FirstRow”)= LastR -1 Then
Columns(x).EntireColumn.Delete
End If
Next x
End Sub
I have an error 13 in the declaration of firstrow function. Why is it so?