Hello again,
I think it would be virtually impossible for anyone to understand your
requirements without viewing the original thread where this all came from -
Subject: Total up values for one month
Date:1 Aug 07
Use separate arrays for totals and if required month names, eg
Sub test2()
Dim arrTotals(1 To 12, 1 To 1) As Double
Dim arrMonths(1 To 12, 1 To 1) As Long
Dim arrMonthsNames(1 To 12, 1 To 1) As String
Dim arr
Dim i As Long, m As Long
With Range("G6") ' top of dates column, values to right
arr = .Resize(.End(xlDown).Row - .Row + 1, 2)
End With
For i = 1 To UBound(arr)
m = Month(arr(i, 1))
arrTotals(m, 1) = arrTotals(m, 1) + arr(i, 2)
Next
Range("P1:P12").Value = arrTotals
' Month numbers next to totals if required
For i = 1 To 12
arrMonths(i, 1) = i
Next
Range("O1:O12").Value = arrMonths
' or Months spelt out
'For i = 1 To 12
'arrMonthsNames(i, 1) = Format(DateSerial(7, i, 20), "mmm")
'Next
'Range("O1:O12").Value = arrMonthsNames
End Sub
Regards,
Peter T
"Les Stout" wrote in message
...
Hi all, i have the code below (Compliments Peter T) that is doing what i
want it to. On hindsight i do not need to show the month with every
list, but just the total. How would i modify the code to show just the
total and not the month ???
Sub test()
Dim arrTotals(1 To 12, 1 To 2) As Double
Dim arr, i As Integer, m As Variant
With Range("G6")
arr = .Resize(.End(xlDown).Row - .Row + 1, 2)
End With
For i = 1 To UBound(arr)
m = Month(arr(i, 1))
arrTotals(m, 2) = arrTotals(m, 2) + arr(i, 2)
Next
For i = 1 To 12
arrTotals(i, 1) = i
Next
Range("O1:P12").Value = arrTotals<-Inserts month and total
End Sub
Best regards,
Les Stout
*** Sent via Developersdex http://www.developersdex.com ***