P
PHisaw
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
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