I have a set of data where every third column is the same. I want to leave only the first column and other which are the same must be deleted.
At first I tried this
I upvoted Mattboy's code as the cleanest
It is possible to avoid the range loop and use an array as you suggest, although I post this more for kicks as the array generation is tricky
Uses Is it possible to fill an array with row numbers which match a certain criteria without looping?
Sub OneinThree()
Dim ws As Worksheet
Dim rng1 As Range
Dim x As String
Set ws = ActiveSheet
Set rng1 = Cells(1, ws.Cells(1, Columns.Count).End(xlToLeft).Column - 2)
x = Join(Filter(Application.Evaluate("=IF(MOD(column(A1:" & rng1.Address & "),3)=0,address(1,column(a1:" & rng1.Address & ")),""x"")"), "x", False), ",")
If Len(x) > 0 Then ws.Range(x).EntireColumn.Delete
End Sub