View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Bernie Deitrick Bernie Deitrick is offline
external usenet poster
 
Posts: 5,441
Default Bold & add line after subtotal row

Pam,

If InStr(1, Cells(r, 3).Value, "Total") 0 Or _

InStr(1, Cells(r, 8).Value, "Total") 0 Or _
InStr(1, Cells(r, 12).Value, "Total") 0 Then
Range(Cells(r, 1), Cells(r, 30)).Font.Bold = True


This code looks for the word Total in column C (3rd column), column H (8th column), or column L
(12th column), and then bolds any row with Total any of those columns from column A to column AD.

You would probably want

If InStr(1, Cells(r, 7).Value, "Total") 0 Then
Cells(r, 1).EntireRow.Font.Bold = True
End If

which will look for the word Total in column G, and bold the entire row when that is true.

HTH,
Bernie
MS Excel MVP


"PHisaw" wrote in message
...
I searched messages and found the following code by Chuck from 10/6/06 and
would like to adapt it to my spreadsheet, but can't get it to work. I
changed lastrow = Range ("L" & Rows.Count).End(xlUP).Row from "L" to "G" as
this is the column where my totals are. Will someone please explain this
code, especially the InStr lines? Hopefully, if I understand it better maybe
I can figure out what I'm doing wrong the reason it won't work.

Sub AddRowSubTotalsAssignedTo()
Dim lastrow As Long
Dim r As Long
lastrow = Range("L" & Rows.Count).End(xlUp).Row '"L" is the column that
'contains the GrandTotal
For r = lastrow To 2 Step -1
If InStr(1, Cells(r, 3).Value, "Total") 0 Or _
InStr(1, Cells(r, 8).Value, "Total") 0 Or _
InStr(1, Cells(r, 12).Value, "Total") 0 Then
Range(Cells(r, 1), Cells(r, 30)).Font.Bold = True '30 is number
'of columns from "A" that the macro will BOLD
ActiveSheet.Rows(r + 1).EntireRow.Insert
End If
Next
End Sub

Any help is greatly appreicated!
Thanks,
Pam