Results 1 to 6 of 6

Thread: Select Last Colored Cell in a Named Range
Thanks Thanks: 0 Likes Likes: 0

  1. #1
    New Member
    Join Date
    Nov 2018
    Posts
    14
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Select Last Colored Cell in a Named Range

    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

  2. #2
    MrExcel MVP
    Junior Admin
    Joe4's Avatar
    Join Date
    Aug 2002
    Posts
    51,063
    Post Thanks / Like
    Mentioned
    57 Post(s)
    Tagged
    11 Thread(s)

    Default Re: Select Last Colored Cell in a Named Range

    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?
    TIPS FOR FINDING EXCEL SOLUTIONS
    1. Use the built-in Help that comes with Excel/Access
    2. Use the Search functionality on this board
    3. A lot of VBA code can be acquired by using the Macro Recorder.

    "Give a man a fish, feed him for a day. Teach a man to fish, feed him for life!"

  3. #3
    New Member
    Join Date
    Nov 2018
    Posts
    14
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Select Last Colored Cell in a Named Range

    The cells are being colored manually. It is just multiple cells going down a single column.

  4. #4
    MrExcel MVP
    Junior Admin
    Joe4's Avatar
    Join Date
    Aug 2002
    Posts
    51,063
    Post Thanks / Like
    Mentioned
    57 Post(s)
    Tagged
    11 Thread(s)

    Default Re: Select Last Colored Cell in a Named Range

    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.
    TIPS FOR FINDING EXCEL SOLUTIONS
    1. Use the built-in Help that comes with Excel/Access
    2. Use the Search functionality on this board
    3. A lot of VBA code can be acquired by using the Macro Recorder.

    "Give a man a fish, feed him for a day. Teach a man to fish, feed him for life!"

  5. #5
    New Member
    Join Date
    Nov 2018
    Posts
    14
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Select Last Colored Cell in a Named Range

    PERFECT, thanks a million Moderator.

  6. #6
    MrExcel MVP
    Junior Admin
    Joe4's Avatar
    Join Date
    Aug 2002
    Posts
    51,063
    Post Thanks / Like
    Mentioned
    57 Post(s)
    Tagged
    11 Thread(s)

    Default Re: Select Last Colored Cell in a Named Range

    You are welcome!
    Glad it worked out for you.
    TIPS FOR FINDING EXCEL SOLUTIONS
    1. Use the built-in Help that comes with Excel/Access
    2. Use the Search functionality on this board
    3. A lot of VBA code can be acquired by using the Macro Recorder.

    "Give a man a fish, feed him for a day. Teach a man to fish, feed him for life!"

Some videos you may like

User Tag List

Tags for this Thread

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •