Log inUsernamePassword
Log me on automatically each visit    
Register
Register
Log in to check your private messages
Log in to check your private messages
Visual Basic Forum for Visual Basic Programmers VB Forum Index » Visual Basic for Applications

Post new topic   Reply to topic
subtotal ?
View previous topic :: View next topic  
Author Message
sirgeoff
Newbie


Joined: 06 Apr 2004
Posts: 2

PostPosted: Apr 6th, 2004 04:09 PM    Post subject: subtotal ? Reply with quote

I'm trying to subtotal at the bottom of column a,b,c,d(at line insert). I'm having difficulty identifying the range, since it is changing with n. Any idea?


For n = 3 To 999
Cells(n, 1).Select
If (Cells(n, 1)) = "" Then


Selection.PasteSpecial paste:=xlPasteValuesAndNumberFormats, Operation:= _
xlNone, SkipBlanks:=False, Transpose:=False

different_month = DateDiff("m", CDate(Cells(n, 5).Value), CDate(Cells(n - 1, 5).Value))

Else: GoTo 12
End If

If different_month <> 0 Then

Selection.Insert Shift:=xlDown
With Selection.Interior
.ColorIndex = 34
.Pattern = xlSolid
End With

Cells(n, 6).Select
ActiveCell.FormulaR1C1 = "Monthly Total"


ActiveSheet.Cells(n, 1).Formula = "=Sum(a1:a5)"

Exit For
End If
12 Next n
e.i.


4.0 0.5 0.1 0.0 2/28/2004
4.0 0.5 0.1 0.0 3/1/2004

4.0 0.5 0.1 0.0 3/2/2004

..............................................................................
..............................................................................
..............................................................................
..............................................................................
3.2 0.5 0.1 0.0 3/31/2004
________________________________________Monthly total
4.0 0.5 0.1 0.0 4/1/2004

Therefore I would need to datediff some how back to February 28 to subtotal the columns for March. I just can't grasp how to get the range to read correctly.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Visual Basic Forum for Visual Basic Programmers VB Forum Index » Visual Basic for Applications All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Visual Basic Forum runs phpBB | Forum Template © iOptional
VB Resources | SSL | Visual Basic