Thank you for reading my post. I have a spreadsheet that contains a table (Table2) with 10K + rows. Column D is labeled "Master Name." Column E is labeled "Child Name???" I have a VBA that colors the row Gray when a P is in the "Master Name" column. I need to add another Conditional Format that would Bold all of the text in a row where a "c" is in Column E "Child Name???" column. These conditions are not dependant upon each other with the exception that if Column D has a "P", Column E can not have a "c." If a row does not have a "P" or a "c" if should not have any color or bold.
I can't use a regular Conditional Format because it slows my worksheet considerably.
The complete VBA is below - The portion of with the existing Condiitonal VBA is at the bottom. The existing VBA is attached to a command button. The sample worksheet is attached.
I really appreciate your help. I am not very savvy with VBA so I appreciate your patience.
Private Sub CommandButton1_Click()
Dim myActiveCell As Range
Set myActiveCell = Selection
myActiveCell.AddComment "StartCell"
Range("Table2[[#Headers],[Order]]").Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlDown)).Select
ActiveWorkbook.Worksheets("Sheet1").ListObjects("Table2").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Sheet1").ListObjects("Table2").Sort.SortFields.Add2 _
Key:=Range("Table2[Master Account Number]"), SortOn:=xlSortOnValues, Order _
:=xlAscending, DataOption:=xlSortNormal
ActiveWorkbook.Worksheets("Sheet1").ListObjects("Table2").Sort.SortFields.Add2 _
Key:=Range("Table2[Master order]"), SortOn:=xlSortOnValues, Order:= _
xlAscending, DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("Sheet1").ListObjects("Table2").Sort
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Cells.Find(What:="StartCell", After:=Range("A1"), LookIn:=xlComments, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate
Selection.ClearComments
Dim LastRow As Long, c As Range
Dim MyRange As Range
LastRow = Cells(Cells.Rows.Count, "D").End(xlUp).Row
Set MyRange = Range("D1:D" & LastRow)
For Each c In MyRange
If UCase(Trim(c.Value)) = "P" Then
c.Offset(, -3).Resize(, 14).Interior.Color = RGB(231, 230, 230)
Else
c.EntireRow.Interior.Color = xlNone
End If
Next
End Sub
Bookmarks