VBA Background color if?

jamada

Active Member
Joined
Mar 23, 2006
Messages
323
Hi

Col H has every second row colored with a grey scale backround.

For each of the rows colored I would like Columns I and J to also match the backround color in Col H?.


Or for that matter, I would like to have Columns I:J match the back ground colors of identical rows in column H.

Is this easy?

Tks jamada
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
Possibly...

Code:
Sub xxx()
    Range("H1:H" & Range("H" & Rows.Count).End(xlUp).Row).Copy
    Range("I1:J" & Range("H" & Rows.Count).End(xlUp).Row).PasteSpecial (xlPasteFormats)
    Application.CutCopyMode = False
End Sub

or

Code:
 Sub xxx2()
    Dim c As Range
    Application.ScreenUpdating = False
    For Each c In Range("I1:J" & Range("H" & Rows.Count).End(xlUp).Row)
        c.Interior.ColorIndex = c.Offset(, -1).Interior.ColorIndex
    Next
    Application.ScreenUpdating = True
End Sub

depending if there is other formatting you want copied or not. Test on a copy of your sheet.
Or just use the format painter.
 
Upvote 0

Forum statistics

Threads
1,222,028
Messages
6,163,477
Members
451,838
Latest member
DonSlayer

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