Subtotals and Conditional Formatting

1kat

New Member
Joined
Aug 16, 2011
Messages
3
I need to regularly scan a large excel spreadsheet that has a Subtotal filter applied to it. I need to find and highlight specific Subtotal Groups that match a criteria.

Below is a screenshot of my example.

My criteria is, if a subtotal group has the same Teller (column C) for all of the lines in that group then I need to identify that group either by highlighting the whole group or just one row in it. I just need to easily scroll through the spreadsheet and find the groups where all the tellers are the same.

In my below example, the second group matches my criteria (rows 11-15) because all the tellers are john.

I would really appreciate some help as I've been messing with this for quite some time and cannot figure out how to do it. It's fine if the solution is not using conditional formatting to highlight the groups, I just need to be able to easily identify the groups where the tellers are all the same without having to scroll through the entire spreadsheet to manually pick them out myself.

Thanks in advance!


example.jpg
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
I was not able to transfer to gif into excel. So I prepared a sample data as below

Excel Workbook
ABCDEFG
1hdng1hdng2hdng3hdng4hdng5hdng6hdng7
2john
3john
4david
5david
6michael count4
7john
8john
9john
10john
11david countg4
12jane
13jane
14jane
15david
16david
17david
18david
19david
20nicole count8
Sheet1



on this sample try this macro

Code:
Sub test()
Dim r As Range, r1 As Range, add As String
Dim j As Integer, k As Integer
Set r = Range("D1")
Set r1 = Columns("D:D").Cells.Find(what:="count", lookat:=xlPart)
add = r1.Address
j = WorksheetFunction.CountA(Range(Cells(r.Row, "C"), Cells(r1.Row, "C")))
k = WorksheetFunction.CountIf(Range(Cells(r.Row, "C"), Cells(r1.Row, "C")), r1.Offset(-1, -1))
If j = k Then
Cells(r1.Row, "C").EntireRow.ColorIndex = 3
End If
Do
Set r = r1
Set r1 = Cells.FindNext(r1)
If r1 Is Nothing Then Exit Do
If r1.Address = add Then Exit Do
j = WorksheetFunction.CountA(Range(Cells(r.Row, "C"), Cells(r1.Row, "C")))
k = WorksheetFunction.CountIf(Range(Cells(r.Row, "C"), Cells(r1.Row, "C")), r1.Offset(-1, -1))
If j = k Then
Cells(r1.Row - 1, "C").EntireRow.Interior.ColorIndex = 3
End If
Loop
End Sub
 
Upvote 0
I have modified the macro now try


Code:
Sub test()
Dim r As Range, r1 As Range, add As String
Dim j As Integer, k As Integer
Set r = Range("D1")
Set r1 = Columns("D:D").Cells.Find(what:="count", lookat:=xlPart)
add = r1.Address
j = WorksheetFunction.CountA(Range(Cells(r.Row + 1, "C"), Cells(r1.Row - 1, "C")))
k = WorksheetFunction.CountIf(Range(Cells(r.Row + 1, "C"), Cells(r1.Row - 1, "C")), r1.Offset(-1, -1))
If j = k Then
'Cells(r1.Row, "C").EntireRow.ColorIndex = 3
Range(Cells(r.Row + 1, "C"), Cells(r1.Row - 1, "C")).Interior.ColorIndex = 3

End If
Do
Set r = r1
Set r1 = Cells.FindNext(r1)
If r1 Is Nothing Then Exit Do
If r1.Address = add Then Exit Do
j = WorksheetFunction.CountA(Range(Cells(r.Row + 1, "C"), Cells(r1.Row - 1, "C")))
k = WorksheetFunction.CountIf(Range(Cells(r.Row + 1, "C"), Cells(r1.Row - 1, "C")), r1.Offset(-1, -1))
If j = k Then
'Cells(r1.Row - 1, "C").EntireRow.Interior.ColorIndex = 3
Range(Cells(r.Row + 1, "C"), Cells(r1.Row - 1, "C")).Interior.ColorIndex = 3
End If
Loop
End Sub


Code:
Sub undo()

ActiveSheet.Cells.Interior.ColorIndex = xlNone
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,527
Messages
6,179,334
Members
452,907
Latest member
Roland Deschain

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