Formatting of Menu/Data/Subtotals

shdawson

Active Member
Joined
Jan 6, 2007
Messages
381
Hi,


Not sure this is the place to ask, but will start here.

Have a massive report that would be nicely served by the Subtotals option on the menu. My question is about formatting of that data. After the *many* rows subtotal, would be nice to bold those rows. The said row will change with each report run, so it is a manual thing now.

Is there a cool plugin out there on the web or something that would assist with the formatting of the subtotaled information? Or, anther trick?


Thank You,
SHD
 
But maybe this would be more flexible

Code:
Sub BoldSbttls()
Dim i As Long, LR As Long, r As Range, c As Integer
On Error Resume Next
Set r = Application.InputBox("Click in the column containing the word Total", Type:=8)
If r Is Nothing Then Exit Sub
On Error GoTo 0
c = r.Column
LR = Cells(Rows.Count, c).End(xlUp).Row
For i = 3 To LR
    If Cells(i, c).Value Like "* Total" Then Rows(i).Font.Bold = True
Next i
End Sub
 
Upvote 0

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
Hi,


Question about enhancing VBA, please.

Vog was kind enough to edit his code...

Code:
Sub BoldSbttls()
Dim i As Long, LR As Long
LR = Range("A" & Rows.Count).End(xlUp).Row
For i = 3 To LR
    If Range("A" & i).Value Like "* Total" Then
        Rows(i).Font.Bold = True
        Rows(i).Interior.ColorIndex = 15
    End If
Next i
End Sub


...to color the rows. Now, some of the columns have conditional formatting to make the font white, which is the same as the background, if the cell results with a 0 (zero). The VBA code makes for a nice gray background with a white 0.

How does one overcome conditional formatting with VBA, please?


Thanks,
S
 
Upvote 0
Try

Code:
Sub BoldSbttls()
Dim i As Long, LR As Long
LR = Range("A" & Rows.Count).End(xlUp).Row
For i = 3 To LR
    If Range("A" & i).Value Like "* Total" Then
        Rows(i).Font.Bold = True
        Rows(i).Interior.ColorIndex = 15
        Rows(i).FormatConditions.Delete
    End If
Next i
End Sub
 
Upvote 0
Hi,


Not sure what changed, but this code now over formats...so to speak.

Code:
Sub BoldingSubtotaledRows()
'ADJUST THE ***RANGE*** TO BE WHATEVER IT NEEDS TO BE...
'A is "Tower"...
Dim i As Long, LR As Long
LR = Range("A" & Rows.Count).End(xlUp).Row
For i = 3 To LR
    If Range("A" & i).Value Like "* Total" Then
        Rows(i).Font.Bold = True
        Rows(i).Interior.ColorIndex = 15
        Rows(i).FormatConditions.Delete
    End If
Next i
End Sub

The code now formats all cells in the said row to gray, where it only did the rows that were accounted for in the subtotaling orginally.

What changed, please?


Thanks,
S
 
Upvote 0

Forum statistics

Threads
1,224,625
Messages
6,179,958
Members
452,950
Latest member
bwilliknits

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