0
Sub Worksheet_Combine()
    Dim i As Long
    Dim j As Long

    For i = 1 To 3
        For j = 7 To 10
            If Cells(1, i) = Cells(1, j) Then
                Cells(1, j).EntireColumn.Select

        Next j
    Next i
End Sub

Running the Sub procedure above throws the following error:

enter image description here

What am I doing wrong?

Pᴇʜ
  • 53,845
  • 9
  • 46
  • 68
HKS
  • 356
  • 2
  • 20
  • You forgot your `End If` before the `Next j` – braX May 30 '22 at 05:27
  • @HKS I indeted your code properly. If you keep proper formatting of the code it is easier to see what is wrong. You might benefit from reading [How to avoid using Select in Excel VBA](https://stackoverflow.com/questions/10714251/how-to-avoid-using-select-in-excel-vba). – Pᴇʜ May 30 '22 at 08:10

0 Answers0