VBA to fill color with multiple rows

Milos

Board Regular
Joined
Aug 28, 2016
Messages
121
Office Version
  1. 365
Platform
  1. Windows
Hi all,

I am looking for VBA to fill color (red) when I select a certain range of rows. I will assign a hotkey for this and then select multiple rows and hit the hot key to fill the row with color. Currently I have a code that works for the first row that has been selected (i.e. one row at a time).

Can somebody please help me add to this code so that I can change the color of more than one row at a time, or alternatively all active cells?

Code:
Sub fill_color_rows()
Rows(ActiveCell.Row).Interior.ColorIndex = 28
End Sub

Thanks team,
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
Can somebody please help me add to this code so that I can change the color of more than one row at a time, or alternatively all active cells?

Code:
Sub fill_color_rows()
[B][COLOR="#FF0000"]Rows(ActiveCell.Row).Interior.ColorIndex = 28[/COLOR][/B]
End Sub
Try replacing the highlighted line of code with this one...

Selection.EntireRow.Interior.ColorIndex = 28
 
Upvote 0
I knew it was going to be a tiny fix.

Brilliant! Thanks Rick.
 
Upvote 0

Forum statistics

Threads
1,223,099
Messages
6,170,109
Members
452,302
Latest member
TaMere

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top