If you find any post useful then, please do share with others. Thanks!

Popular Posts


Email me

Need help and that also free? I like to learn this way, in case of any question or for a small task, please feel free to email me with details and example data, if required.

Wednesday, September 17, 2014

Excel Macro: Highlight Every Other Row

Excel Macro: Highlight Every Other Row

Select the rows and run the below Macro (VB Code), this will highlight the every other row of your selection.
Saving Macro Code & assigning it to a button
For this first save the code, by going to Developer Tab and then clicking the Visual Basic. (If you don’t see Developer tab (Excel 2010) then go to the "File tab -> Options (under Help) -> Customize ribbon" and there tick the box of the Developer ribbon )
A new window will open now click on Insert > Module, paste the code there save and close the window. Now for putting a button in your sheet, go to Developer tab then Insert then Click on button (Form Control). Place it where you want.
Now right click on it and click on Assign Macro and assign this Highlight macro to that button. So now after you select your rows, clicking on this button will run the macro.

Sub Highlight()
Dim r As Integer
For r = 1 To Selection.Rows.Count
If r Mod 2 = 1 Then
Selection.Rows(r).Interior.ColorIndex = 37
End If
End Sub

1 comment: