Q:

In Excel VBA how can I format every other merged cell in a row? 

I have some code that merges 52 columns into the months of a given year. 
See Row 5 and 6 below

My code merges cells that have a common month however for row 6 I would like to format every other merged cell so it is filled black, the font is white and a formula is put into A6 and autofilled right i.e the second merged cell in row 6 under Feb is = pervious cell (under Jan) - 1. 

The code below is provided by user CMArg and almost achieves what I am trying to do...
The result is this

Dim TempRange, TempRange2 As Range
Dim a, c, i, z As Integer

Sub MergeAndPaint()
        z = 60 'the first value in row 6
        a = 1
        For i = 1 To 260 '260 is number of columns up to IZ
            If Worksheets("MASTER").Cells(5, i).Value <> Worksheets("MASTER").Cells(5, i + 1).Value Then
                Set TempRange = Range(Worksheets("MASTER").Cells(5, a), Worksheets("MASTER").Cells(5, i))
                Set TempRange2 = Range(Worksheets("MASTER").Cells(6, a), Worksheets("MASTER").Cells(6, i))

                With TempRange
                    .Merge
                    .HorizontalAlignment = xlCenter
                    .VerticalAlignment = xlCenter
                End With

                With TempRange2
                    .Merge
                    .HorizontalAlignment = xlCenter
                    .VerticalAlignment = xlCenter
                    .Value = z
                    If a Mod 2 = 0 Then
                        .Interior. Pattern = xlSolid
                        .Interior. PatternColorIndex = xlAutomatic
                        .Interior. ThemeColor = xlThemeColorLight1
                        .Font. ThemeColor = xlThemeColorDark1
                    End If
                End With

                a = i + 1
                z = z - 1
            End If
        Next
End Sub

A:

I think this code will perform what you want to achieve, but is shorter and clearer.  See the new EDITED code. 
    Dim TempRange, TempRange2 As Range
    Dim a, i, z, d As Integer

    Sub MergeAndPaint()
            z = 60 'the first value in row 6
            a = 1 'variable used for setting ranges
            d = 2 'for counting odd and even
            For i = 1 To 260 '260 is number of columns up to IZ
                If Worksheets("MASTER").Cells(5, i).Value <> Worksheets("MASTER").Cells(5, i + 1).Value Then
                    Set TempRange = Range(Worksheets("MASTER").Cells(5, a), Worksheets("MASTER").Cells(5, i))
                    Set TempRange2 = Range(Worksheets("MASTER").Cells(6, a), Worksheets("MASTER").Cells(6, i))

                    With TempRange
                        .Merge
                        .HorizontalAlignment = xlCenter
                        .VerticalAlignment = xlCenter
                    End With

                    With TempRange2
                        .Merge
                        .HorizontalAlignment = xlCenter
                        .VerticalAlignment = xlCenter
                        .Value = z
                        If d Mod 2 = 0 Then
                            .Interior. Pattern = xlSolid
                            .Interior. PatternColorIndex = xlAutomatic
                            .Interior. ThemeColor = xlThemeColorLight1
                            .Font. ThemeColor = xlThemeColorDark1
                        End If
                    End With
                    d = d + 1
                    a = i + 1
                    z = z - 1
                End If
            Next
    End Sub

