John Sadler
New Member
- Joined
- May 1, 2012
- Messages
- 48
Folks ... got this VBA to sum cells in specific sheets and put the values in the first row of a table in my Welcome sheet.
How do I get this to loop through the additional 11 rows in the sheets to fill the 11 rows in my table?
I have lined up the data somewhat as Sum of Q9 goes to Q9 in my Welcome sheet so Sum Q10 to Q10, Sum Q11 to Q11 etc
Sub SumIntPWSalesSheets()
' Sum PW Sales in Active Internal Sales Sheets
Application.ScreenUpdating = False
Dim ws As Worksheet
Dim Cell As Range
Dim Sum As Currency
Dim Sum2 As Currency
Sum = 0
Sum2 = 0
For Each ws In Worksheets
If ws.Range("U1") = "Active" And ws.Range("U2") = "Internal" Then
Sum = Sum + ws.Range("R9").Value
Sum2 = Sum2 + ws.Range("Q9").Value
End If
Next ws
Sheets("Welcome").Range("R9").Value = Sum
Sheets("Welcome").Range("Q9").Value = Sum2
Application.ScreenUpdating = True
End Sub
How do I get this to loop through the additional 11 rows in the sheets to fill the 11 rows in my table?
I have lined up the data somewhat as Sum of Q9 goes to Q9 in my Welcome sheet so Sum Q10 to Q10, Sum Q11 to Q11 etc
Sub SumIntPWSalesSheets()
' Sum PW Sales in Active Internal Sales Sheets
Application.ScreenUpdating = False
Dim ws As Worksheet
Dim Cell As Range
Dim Sum As Currency
Dim Sum2 As Currency
Sum = 0
Sum2 = 0
For Each ws In Worksheets
If ws.Range("U1") = "Active" And ws.Range("U2") = "Internal" Then
Sum = Sum + ws.Range("R9").Value
Sum2 = Sum2 + ws.Range("Q9").Value
End If
Next ws
Sheets("Welcome").Range("R9").Value = Sum
Sheets("Welcome").Range("Q9").Value = Sum2
Application.ScreenUpdating = True
End Sub