PDA

View Full Version : pull letter above after subtotal



preseb
04-14-2011, 06:16 AM
After I run my subtotal:
Range("A:O").Subtotal GroupBy:=2, _
Function:=xlSum, _
TotalList:=Array(9, 10, 11, 12, 13), _
Replace:=True, _
PageBreaks:=False, _
SummaryBelowData:=True

ActiveSheet.Outline.ShowLevels RowLevels:=2

How can I pull the character in column 3? I was hoping in include in the subtotal and then just replece the subtotal with an offset, but I could not get that to work.

Here is what the first subtotal looks like if I am subtotaling column 3: =SUBTOTAL(9,C2:C86) - all of those cells contains the same 1 letter character. I want to pull that down to the subtotal line.

Suggestions?

BrianMH
04-14-2011, 08:42 AM
can you upload a sample please?

preseb
04-14-2011, 10:20 AM
You want me to upload a sample of the file? unfortunately I cannot. It contains some confidential information.

I will see if I can save a copy without those detials. thanks

preseb
04-14-2011, 10:25 AM
ok try this. I wrote over any confidential info.

BrianMH
04-14-2011, 11:34 AM
ok I'm not clear what you want to pull and where you want it to be.

Are you wanting to come up with A - 1,229,016?

preseb
04-14-2011, 11:37 AM
If I apply the subtotal, in row 87 I would have column B saying A Total. Next to that (Column C) I am trying to pull the M that is listed with all of those A's.

BrianMH
04-14-2011, 12:11 PM
Sub test()

Dim rwBottom As Long
Dim c As Range

Range("A:O").Subtotal GroupBy:=2, _
Function:=xlSum, _
TotalList:=Array(9, 10, 11, 12, 13), _
Replace:=True, _
PageBreaks:=False, _
SummaryBelowData:=True

ActiveSheet.Outline.ShowLevels RowLevels:=2

rwBottom = Cells(ActiveSheet.Rows.Count, 2).Row
For Each c In Range("B1:B" & rwBottom)
If c.EntireRow.Hidden = False And UCase(c.Value) Like "*TOTAL*" Then
c.Offset(, 1).Value = c.Offset(-1, 1).Value
End If
Next

End Sub




Probably not the cleanest but it seems to work

preseb
04-14-2011, 12:14 PM
perfect - thank you