Subscript out of range on RGB?

jkwleisemann

New Member
Joined
May 31, 2016
Messages
19
I'm trying to set the interior color of a row, and for some reason I'm getting a "subscript out of range" error when I use the Interior.ColorIndex property. The goal is to mark Saturdays and Sundays in a chart. Code follows; any tips?

Code:
If WorksheetFunction.Weekday(datWork, 1) = 1 Or WorksheetFunction.Weekday(datWork, 1) = 7 Then
            Worksheets(4).Range(12 + i & ":" & 12 + i).Interior.ColorIndex = RGB(128, 128, 128)
        End If
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
ColorIndex doesn't support RGB. Try using .Interior.Color instead.
 
Last edited:
Upvote 0
Thank you! Worked perfectly. Why can't the Help write-ups be this useful?

Happy to be of service. And as Jonmo1 states, it would put us helpers out of work. I kinda like it around here. :)
 
Upvote 0

Forum statistics

Threads
1,215,035
Messages
6,122,791
Members
449,095
Latest member
m_smith_solihull

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