1

I'm trying to merge every second cell going trough columns, starting at the 12.column till last used column, but the code isn't working. Can somebody point out a mistake that I'm making?

For i = 13 To lCol Step 2
    Sheet9.Range(Sheet9.Cells(3, i), Sheet9.Cells(3, i + 1)).Merge
Next i
1
  • @pnuts Can you explain why? This is my header, it just starts in third row. Commented May 7, 2018 at 11:43

1 Answer 1

1

Using 20 as a hardcoded value for last column and the code below:

Public Sub TetMe()

    Dim i As Long

    For i = 1 To 20 Step 2
        With Worksheets(1)
            .range(.Cells(3, i), .Cells(3, i + 1)).Merge
        End With
    Next i

End Sub

you will get a result like this:

enter image description here

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you so much, this pushed me in the right direction and, with a little bit of adapting of your code, its now working perfectly.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.