Monday, July 1, 2019

Macro to highlight alternate cells in excel | VBA to highlight alternate cells in excel

Macro to highlight alternate cells in excel | VBA to highlight alternate cells in excel 


Open Excel Sheet


Press Alt + F11 Key 


Go to the Insert Menu and Click on new Module


in New Module copy and paste the above VBA code and save.


Now Press Alt + F8  and new windows will open which is shown in below figure,


in that windows, you will ask to enter a key to create a shortcut for Paste Special


Enter a letter in the box. 


Macro to highlight alternate cells in excel | VBA to highlight alternate cells in excel 


Sub HighlightAlternateRows()
Dim Myrange As Range
Dim Myrow As Range
Set Myrange = Selection
For Each Myrow In Myrange.Rows
   If Myrow.Row Mod 2 = 1 Then
      Myrow.Interior.Color = vbCyan
   End If
Next Myrow
End Sub