Setting background color of range 2010 vs 2013

Galt

New Member
Joined
Nov 9, 2012
Messages
5
I recently started using Excel 2013 on one of my computers and was transferring over some VBA from my personal workbook. One of these programs highlights cells using essentially the code below.

Code:
ActiveSheet.Cells(3,1).Interior.Color = RGB(255,255,255)

This line of code no longer works in Excel 2013 and I can't figure out why. I'm wondering if it has something to do with the Single Document Interface. When I run the line of code above in the Immediate window of my 2010 version it changes the cell color but in 2013 it throws a Run-time error 1004 Application-defined or object-defined error. The documentation on MSDN doesn't seem to callout any changes to these properties. If I replace the .Interior.Color with .Select it selects the correct cell so it seems like my reference to the cell is working correctly.

If anyone has any insight it would be greatly appreciated.
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
Hi Galt - The color you chose, RGB (255, 255, 255) is white, so when I run this it looks like it doesn't do anything. Try RGB(0, 255, 255) and let us know what happens. If that isn't the problem, you might try:

Code:
Sub Galt_ColorTest()
    ActiveSheet.Cells(3, 1).Select
    With Selection
        .Interior.Color = RGB(0, 255, 255)
    End With
End Sub
 
Upvote 0
Hi goesr,

Thanks for the response but this issue actually seems to have resolved itself. I'm not sure why but I closed Excel and then later on in the day retried both the problematic line code in the immediate window and running the program and it worked fine without throwing the error. Hopefully it was just a one time bug. Thanks again.
 
Upvote 0

Forum statistics

Threads
1,214,873
Messages
6,122,029
Members
449,061
Latest member
TheRealJoaquin

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