View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Pman Pman is offline
external usenet poster
 
Posts: 36
Default Column totals depending on different criteria

Just one more help JR,

Is it possible to past-special the totals that are derived from your macro,
and shift it one cell to the left? My client wants the totals to come below
the dates in the date columns and delete the cost columns (please refer the
image I posted above) :(

Please please please do help me out.

Thanks,

Prash

"JRForm" wrote:

you welcome.

"Pman" wrote:

Thank you JrForm,

That worked like a charm :) You are a life saver :)

Thanks again,

Prash :)

"JRForm" wrote:

Pman,

Delete the code I already posted and paste in the code here in this post.
This will total the columns you posted.
Sub Pman()

Dim iLastRow As Long
Dim look4Me As String
Dim vAddingUp(14) As Variant
Dim k As Integer
iLastRow = Range("A" & Range("A:A").Rows.Count).End(xlUp).Row
'change to the column you want to search

Range("A1").Select 'go to the top of the column to begin searching

Do Until iLastRow = -1
If ActiveCell < "" Then look4Me = ActiveCell

If ActiveCell = look4Me Then
vAddingUp(1) = vAddingUp(1) + ActiveCell.Offset(0, 9)
vAddingUp(2) = vAddingUp(2) + ActiveCell.Offset(0, 11)
vAddingUp(3) = vAddingUp(3) + ActiveCell.Offset(0, 13)
vAddingUp(4) = vAddingUp(4) + ActiveCell.Offset(0, 15)
vAddingUp(5) = vAddingUp(5) + ActiveCell.Offset(0, 17)
vAddingUp(6) = vAddingUp(6) + ActiveCell.Offset(0, 19)
vAddingUp(7) = vAddingUp(7) + ActiveCell.Offset(0, 21)
vAddingUp(8) = vAddingUp(8) + ActiveCell.Offset(0, 23)
vAddingUp(9) = vAddingUp(9) + ActiveCell.Offset(0, 25)
vAddingUp(10) = vAddingUp(10) + ActiveCell.Offset(0, 27)
vAddingUp(11) = vAddingUp(11) + ActiveCell.Offset(0, 29)
vAddingUp(12) = vAddingUp(12) + ActiveCell.Offset(0, 31)
vAddingUp(13) = vAddingUp(13) + ActiveCell.Offset(0, 32)
vAddingUp(14) = vAddingUp(14) + ActiveCell.Offset(0, 33)
Else

ActiveCell.Offset(0, 9) = vAddingUp(1)
ActiveCell.Offset(0, 11) = vAddingUp(2)
ActiveCell.Offset(0, 13) = vAddingUp(3)
ActiveCell.Offset(0, 15) = vAddingUp(4)
ActiveCell.Offset(0, 17) = vAddingUp(5)
ActiveCell.Offset(0, 19) = vAddingUp(6)
ActiveCell.Offset(0, 21) = vAddingUp(7)
ActiveCell.Offset(0, 23) = vAddingUp(8)
ActiveCell.Offset(0, 25) = vAddingUp(9)
ActiveCell.Offset(0, 27) = vAddingUp(10)
ActiveCell.Offset(0, 29) = vAddingUp(11)
ActiveCell.Offset(0, 31) = vAddingUp(12)
ActiveCell.Offset(0, 32) = vAddingUp(13)
ActiveCell.Offset(0, 33) = vAddingUp(14)
'reset for next pub

For k = 1 To 14
vAddingUp(k) = 0
Next k

End If
iLastRow = iLastRow - 1
ActiveCell.Offset(1, 0).Select
Loop

End Sub