Hello!
I have Microsoft Home and Student 2013.
I have a macro that loops through all worksheets that contain letter "P":
[FONT="]
[FONT="]
However, recently I started noticing it doensn't sum up everything. This is really weird.
For example: in one of the most recent sheets I have an entry in H2 - and it's counted by the macro.
But after I add some amount in H3 - it's not counted by the macro! the format for both H2 and H3 is identical - 'currency'.
Even more weird - in my recent sheet the amount in H2 is counted by the macro. But when I add 100 in H3, the macro adds only 75 (!). And if I add 50 in H3, then the macro adds only 25!
How is it even possible!?
When I try to add some amount on older sheets, the whole amount is taken into account.
Any thoughts on what might be wrong? Maybe, somehow, I have too many sheets? But in this case - why is the macro taking into account the whole value in H2 but only part of the value in H3 (or not at all)?
I am at the end of my wits.
Thank you very much![/FONT]
I have Microsoft Home and Student 2013.
I have a macro that loops through all worksheets that contain letter "P":
[FONT="]
Sub MonthSumsH()
' Calculate the sum total in column H across all sheets that have letter P in their name
Dim ws As Worksheet
Dim LR As Long
Dim MySum As Long
Dim MyCell As Range
Dim MyMonth As String
Application.ScreenUpdating = False
MyMonth = Format(Range("H4").Value, "mmyyyy")
For Each ws In Worksheets
If InStr(1, ws.Name, "P") > 0 Then
LR = ws.Cells(Rows.Count, "G").End(xlUp).Row
MySum = MySum + Evaluate("=SUMPRODUCT(--(TEXT(<wbr>'" & ws.Name & "'!G3:G" _
& LR & ",""mmyyyy"")=""" & MyMonth & """),'" & ws.Name & "'!H3:H" & LR & ")")
End If
Next ws
Range("I4").Value = MySum
End Sub
[/FONT][FONT="]
However, recently I started noticing it doensn't sum up everything. This is really weird.
For example: in one of the most recent sheets I have an entry in H2 - and it's counted by the macro.
But after I add some amount in H3 - it's not counted by the macro! the format for both H2 and H3 is identical - 'currency'.
Even more weird - in my recent sheet the amount in H2 is counted by the macro. But when I add 100 in H3, the macro adds only 75 (!). And if I add 50 in H3, then the macro adds only 25!
How is it even possible!?
When I try to add some amount on older sheets, the whole amount is taken into account.
Any thoughts on what might be wrong? Maybe, somehow, I have too many sheets? But in this case - why is the macro taking into account the whole value in H2 but only part of the value in H3 (or not at all)?
I am at the end of my wits.
Thank you very much![/FONT]