+ Reply to Thread
Results 1 to 3 of 3

Conditional Format based on Text String

  1. #1
    Registered User
    Join Date
    05-27-2004
    Posts
    23

    Conditional Format based on Text String

    Does anybody know how to conditionally format a cell based on a text string?

    For Example: I would like the background of the cell to be blue and the font white if the text starts with I or V or X (Roman Numeral).

    Thanks!

  2. #2
    Forum Contributor
    Join Date
    11-09-2004
    Posts
    451
    I don't think it is possible to solve without using macro

    Try this macro


    Sub macro()
    Dim ini As Variant
    Dim k, k1 As Variant

    k = 1

    Cells.Select
    While ActiveCell.Address <> ini Or k = 2
    On Error Resume Next
    Cells.Find(What:="I*", After:=ActiveCell, LookIn:=xlValues, LookAt:= _
    xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=True) _
    .Activate
    If ini <> ActiveCell.Address Then
    End If
    If k = 1 Then
    ini = ActiveCell.Address
    End If

    If Err.Description <> "" Then
    GoTo a3:
    Else
    With ActiveCell.Interior
    .ColorIndex = 33
    .Pattern = xlSolid
    End With
    ActiveCell.Font.Bold = True
    ActiveCell.Font.ColorIndex = 2
    End If
    k = k + 1
    Wend
    a3:
    Err.Clear

    k = 1
    Cells.Select
    Err.Clear
    ini = ""
    While ActiveCell.Address <> ini Or k = 2
    On Error Resume Next
    Cells.Find(What:="X*", After:=ActiveCell, LookIn:=xlValues, LookAt:= _
    xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=True) _
    .Activate
    If ini <> ActiveCell.Address Then
    End If
    If k = 1 Then
    ini = ActiveCell.Address
    End If

    If Err.Description <> "" Then
    GoTo a1:

    Else
    With ActiveCell.Interior
    .ColorIndex = 33
    .Pattern = xlSolid
    End With
    ActiveCell.Font.Bold = True
    ActiveCell.Font.ColorIndex = 2
    End If
    k = k + 1
    Wend
    a1:

    Err.Clear
    k = 1
    ini = ""
    Cells.Select
    While ActiveCell.Address <> ini Or k = 2

    On Error Resume Next
    Cells.Find(What:="V*", After:=ActiveCell, LookIn:=xlValues, LookAt:= _
    xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=True) _
    .Activate
    If ini <> ActiveCell.Address Then
    End If
    If k = 1 Then
    ini = ActiveCell.Address
    End If

    If Err.Description <> "" Then
    GoTo a2:

    Else
    With ActiveCell.Interior
    .ColorIndex = 33
    .Pattern = xlSolid
    End With
    ActiveCell.Font.Bold = True
    ActiveCell.Font.ColorIndex = 2
    End If

    k = k + 1
    Wend
    a2:
    End Sub

  3. #3
    Registered User
    Join Date
    05-27-2004
    Posts
    23
    WOW...I figured it would be a simple conditional fomrat. I will give your macro a shot and see if that will work.

    Thanks!

+ 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