View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Jim G Jim G is offline
external usenet poster
 
Posts: 132
Default Variable Subtotal range

If I have Subtotal Categories in Col A (EG: Total Plant Costs, Total Hire
Costs etc-up to 20 over several hundred rows of data and 12 months in
columns). Each project subtotal will have a different range.

How do I subtotal a column based on a change in subtotal category?

I use the following code to find the current month column based on the data
date and will need to subtotal adjustments one column to the right for each
category change:

Sub FindCurMonthM324()

Dim CurLocation As Range
Dim addr As String
Dim curDate As String
Dim rng As Range

Application.ScreenUpdating = False

curDate = Sheets("Control").Range("B1").Value
Sheets("CheopsM324").Rows(10).NumberFormat = "general"

On Error Resume Next
Set CurLocation = Rows(10).Find(What:=curDate, LookIn:=xlValues)
Set rng = Range(CurLocation.Address)
Debug.Print (rng.Address)

Application.ScreenUpdating = True
If Not CurLocation Is Nothing Then
addr = CurLocation.Address
CurLocation.Offset(3, 0).Select
Else
MsgBox "Period Date Not Found"
End If

Sheets("CheopsM324").Rows(10).NumberFormat = "mmm-yy"

End Sub



--
Jim