Select Last Colored Cell in a Named Range

MyersEPS

New Member
Joined
Nov 2, 2018
Messages
14
Hello,

I am tiring to select the last colored cell in a named range based on a active cell background color. Can someone please help???

Thanks
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
Welcome to the Board!

How is the cell being colored? Manually, via Conditional Formatting, or by VBA?
What are the typical dimensions of this named range? Is it always multiple rows AND multiple columns, or is it just multiple cells going down a single column, or multiple cells going across a single row?
 
Upvote 0
Try this:
Code:
Sub MyLastColoredCell()

    Dim cell As Range
    Dim fndCell As Range
    
'   Loop through all cells in range named "MyRange"
    For Each cell In Range("MyRange")
        If cell.Interior.Color <> 16777215 Then
            Set fndCell = cell
        End If
    Next cell
    
'   Select cell
    If Not fndCell Is Nothing Then
        fndCell.Select
    Else
        MsgBox "No colored cells found in named range"
    End If
    
End Sub
Change the range name to suit.
 
Upvote 0
You are welcome!
Glad it worked out for you.
 
Upvote 0

Forum statistics

Threads
1,214,945
Messages
6,122,397
Members
449,081
Latest member
JAMES KECULAH

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