Too many selects!

Glenn

Active Member
Joined
Sep 20, 2003
Messages
325
Hi,

Could this be simplified please? It's to change the color of some cells that contain formulas.
Code:
    Range("A1").Select
    Range(Selection, Selection.End(xlToRight)).Select
    Range(Selection, Selection.End(xlDown)).Select
    Selection.Interior.ColorIndex = 10
    Range("C7").Select
Thanks, Glenn
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
Hi
try
Code:
With ActiveSheet.Range("a1")
    ActiveSheet.Range(.End(xlDown), .End(xlToRight)) _
    .Interior.ColorIndex = 10
End With
 
Upvote 0
Thanks again Jindon :biggrin:

...code is much faster then I had from the recorder!

Cheers Glenn
 
Upvote 0
Hi,

This is sort of related to the above - I have been trying to work out how to do it but totally lost!

In the sheet using the code above I change the color of some cells (A3:C7) that contain formulas.

Next to the formulas in A3:C7 I have a column in with I want to write some notes but would also like to change the color of this column too.

In otherwords, using say column C3:C7 which includes formulas, can I offset this to change the color in D3:D7?

I've tried stuff like this but it doesn't work:
Code:
        Dim v As Range
        Set v = Range("C65536").End(xlUp)
        With v.Offset(1, 1)
            Range(Selection, Selection.End(xlUp)).Select
            Selection.Interior.ColorIndex = 17
        End With
Thanks for any help.

Cheers, Glenn

Edit: the reason why I'm using the End(xlUp) is because the number of formulas vary down the columns in A B and C.
 
Upvote 0

Forum statistics

Threads
1,214,641
Messages
6,120,692
Members
448,979
Latest member
DET4492

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