[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 249
  • Last Modified:

Set Interior.ColorIndex

Hello Experts,

I need to set my Interior.Color.Index to 15 for every other cell in my range starting with A5, after I set my sheet to merge cells.

So far I have my code as:

Private Sub MergeBlockNames()
   
    For i = 5 To 74 Step 2
    Range(Cells(i, 1), Cells(i + 1, 1)).Merge
    Next i

End Sub

I am confused how to add this next step - can you please help?
Thanks
0
mike637
Asked:
mike637
  • 2
1 Solution
 
kgerbChief EngineerCommented:
You're question in a little unclear.  Is this what you're looking for?  If not we'll need some more explanation.
Private Sub MergeBlockNames()
Dim i As Long, j As Long
j = 1
For i = 5 To 74 Step 2
    j = j + 1
    With Range(Cells(i, 1), Cells(i + 1, 1))
        .Merge
        If j Mod 2 = 0 Then .Interior.ColorIndex = 15
    End With
Next i
End Sub

Open in new window

Kyle
0
 
mike637Author Commented:
That was it!!

Thank you very much Kyle!
0
 
kgerbChief EngineerCommented:
You're welcome.  Glad to help.
Kyle
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now