VBA & Conditional Formatting

th259

New Member
Joined
Oct 24, 2023
Messages
35
Office Version
  1. 365
Platform
  1. Windows
I have a table that was pasted values from a pivot table. The first and second column (Fund and Vendor Name columns) have subtotals. I have the following code to highlight any subtotal rows for column A, but how do I do it for column B?

VBA Code:
Dim myRange As Range
    Set myRange = ThisWorkbook.Worksheets("Summary").Range("A6:J" & Range("J" & Rows.Count).End(xlUp).Row)
    With myRange.Borders
    .LineStyle = xlContinuous
    .ColorIndex = 0
    .TintAndShade = 0
    .Weight = xlThin
    End With
    With myRange
        .FormatConditions.Delete
        .FormatConditions.Add Type:=xlExpression, Formula1:="=AND(NOT(ISBLANK($A6)),ISBLANK($E6))"
           .FormatConditions(.FormatConditions.Count).Interior.Color = 15189684
        End With
    myRange.Select
    Selection.AutoFilter
    ActiveSheet.myRange.AutoFilter Field:=2, Criteria1:=RGB(180, 198, 231), Operator:=xlFilterCellColor
End Sub

I had tried the code below and it didn't work.
VBA Code:
With myRange
        .FormatConditions.Delete
        .FormatConditions.Add Type:=xlExpression, Formula1:="=SEARCH (" * Total * ", $B6)"
           .FormatConditions(.FormatConditions.Count).Interior.Color = 11854022
        End With

Also, how do I filter the Fund column (column A) to only show the rows with the specific blue fill color and delete the word Total from only those filtered rows then add a vlookup formula in column B only for those filtered rows.
 
Last edited:
If that includes the Grand Total row you just need a - 1
Rich (BB code):
Range("B7:B" & Range("J" & Rows.Count).End(xlUp).Row - 1)
 
Upvote 0

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off

Forum statistics

Threads
1,223,886
Messages
6,175,194
Members
452,616
Latest member
intern444

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top