Thanks Bob for your reply.
I see how your solution works but, I forgot to mention that the data
I'm pulling in is dynamic. The first time I pull the data from the
source file(s) there maybe 1 hence, one line or record of data and the
next time there maybe 3500 lines of data (E2:E3501); therefore, I need
to know the last record.
I also found this other function in another post.
Sub Cond_Format_()
Cells.FormatConditions.Delete
Dim r As Range
Set r = Range(Range("E2"), Range("E6500").End(xlUp))
r.Cells.FormatConditions.Add Type:=xlExpression,
Formula1:="=RC5=""Help"""
''''''''''r.EntireRow.FormatConditions(1).Interior .ColorIndex = 3
r.Cells.FormatConditions(1).Interior.ColorIndex = 3
End Sub
I can follow this function and see how it changes the background to red
of any cell between E2:E6500 where that cell is equal to "Help",
but I can't seem to get the right syntax when combining the 3. The
three being:
1. The MaxRow function
2. The Cond_Format_ function
3. Your solution
I would like to use the oRowMax variable from below with r from above.
Instead of Range("E6500").End(xlUp)) I would like to use oRowMax in
place of "E6500". Remember, I'm a newbie with no prior
programming experience of any find and I'm trying to learn on my own.
Sub MaxRow()
'Count the number of rows used in a worksheet
oRowMax = wks.UsedRange.Rows.Count
oRowMax1 = wks.UsedRange.Rows.Count + 1
End Sub
Instead of
r.Cells.FormatConditions.Add Type:=xlExpression,
Formula1:="=RC5=""Help"""
which only test for the cell to be equal to the string "Help", I
would like to test to see if a cell contains any of the other strings
we discussed above (LLC, Corp, etc.).
I see that the following changes the background to Red and the text to
Blue.
r.Cells.FormatConditions(1).Interior.ColorIndex = 3
r.Cells.FormatConditions(1).Font.ColorIndex = 5
Where can I look up the Color Indexes? Remember I want my background
to be wheat or cornsilk or some color like that.
How can I just specify the color and not the index number. I tried
this below but it gave me black.
r.Cells.FormatConditions(1).Interior.Color = Cornsilk
Thanks for any help in advance.
Willie T - Newbie
|