+ Reply to Thread
Results 1 to 2 of 2

find cells in a range that contain '-' symbol and highlight then them

Hybrid View

  1. #1
    Registered User
    Join Date
    04-22-2010
    Location
    Greece
    MS-Off Ver
    Excel 2007
    Posts
    50

    find cells in a range that contain '-' symbol and highlight then them

    Hi all,

    So i have data from a data sheet range: A2:H22

    I want to write a script that will find any cells that contain the negative symbol in their cell '-' and highlight that cell in yellow. (mulitple cells will have negative symbol)

    Names will exist in row that will include that symbol, so I havent included that in the range.

    Can someone point me in the right direction to find a simillar code

    Sub Highlight()

    ThisWorkbook.Sheets("Data").Activate
    Dim LookupRange AS Range
    Dim Check As String

    Set LookupRange = Range("A2:H22")
    Set Check = "-"

    'Maybe a For Each Loop
    'Where check is in lookuprange
    'hightlight cell yellow until done.


    Thanks guys..

  2. #2
    Forum Expert nilem's Avatar
    Join Date
    10-22-2011
    Location
    Ufa, Russia
    MS-Off Ver
    2013
    Posts
    3,377

    Re: find cells in a range that contain '-' symbol and highlight then them

    maybe so
    Sub ert()
    Dim r As Range, adr As String
    With Range("A2:H22").SpecialCells(2, 1)
        Set r = .Find("-")
        If Not r Is Nothing Then
            adr = r.Address
            Do
                r.Interior.ColorIndex = 43
                Set r = .FindNext(r)
            Loop While r.Address <> adr
        End If
    End With
    End Sub
    Pavlos please use code tags

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1