Excel Macro: Highlight Every Other Row
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.
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 )
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
Next
End Sub
Well pointed out. Very handy. Thanks for sharing.
ReplyDelete