+ Reply to Thread
Results 1 to 3 of 3

Findind values in a worksheet and fornatting them

Hybrid View

  1. #1
    Registered User
    Join Date
    07-14-2005
    Posts
    25

    Findind values in a worksheet and fornatting them

    Hi all,

    I need a bit of VB code to run off of a button which when clicked will check a list of values (say in the range J2:J30) and format any other cells on the worksheet to say bold blue text and italic that match the range mentioned before.

    Can anyone help with this?

  2. #2
    Tom Ogilvy
    Guest

    Re: Findind values in a worksheet and fornatting them

    Look at the sample code provided with the FindNext method of the range
    object (in Excel VBA help). It should be easily adaptable to your
    requirement.

    --
    Regards,
    Tom Ogilvy

    "chrisrowe_cr" <[email protected]>
    wrote in message
    news:[email protected]...
    >
    > Hi all,
    >
    > I need a bit of VB code to run off of a button which when clicked will
    > check a list of values (say in the range J2:J30) and format any other
    > cells on the worksheet to say bold blue text and italic that match the
    > range mentioned before.
    >
    > Can anyone help with this?
    >
    >
    > --
    > chrisrowe_cr
    > ------------------------------------------------------------------------
    > chrisrowe_cr's Profile:

    http://www.excelforum.com/member.php...o&userid=25220
    > View this thread: http://www.excelforum.com/showthread...hreadid=390996
    >




  3. #3
    Forum Contributor
    Join Date
    01-21-2005
    Location
    Colorado
    MS-Off Ver
    2000,2003,2007
    Posts
    481
    Here is a modified version of the find next code Tom is referring to.
    Give it a try

    Sub FormatFoundValues()
    Dim entry As Range, foundentry As Range, firstaddress As String
        For Each entry In Range("J2:J30")
        Set foundentry = Cells.find(what:=entry.Value)
            If Not foundentry Is Nothing Then
                firstaddress = foundentry.Address
                Do
                With foundentry.Font
                    .ColorIndex = 5
                    .Bold = True
                    .Italic = True
                End With
                Set foundentry = Cells.FindNext(After:=foundentry)
                Loop While Not foundentry Is Nothing And foundentry.Address <> firstaddress
            End If
        Next entry
    End Sub
    HTH

+ 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