Philip1957
Board Regular
- Joined
- Sep 30, 2014
- Messages
- 185
- Office Version
- 365
- Platform
- Windows
Greetings,
I know just enough VBA to be dangerous, and what I'm attempting is way over my head. I would be grateful for any assistance.
I have a workbook with two sheets named "Tracking" and "Summary". On the Tracking sheet in column A is a number "JobDay" (1 - 5). I want to add the values in Tracking ("M") of each row that has JobDay = 1 in it and paste the sum in Summary ("G4"). I then want to repeat this for JobDay values 2 - 5, pasting the sum in Summary H4, I4, J4, & K4 respectively.
The "JobDay" values in Tracking ("A") will always be grouped together; all the ones in sequential rows, all the twos, etc. The actual range of ones, twos, etc will vary from week to week.
Here's the code I wrote by pulling bits and pieces from other macros and Google before I realized I had no idea how to make this work.
I hope I've explained this clearly enough that it makes sense.
Thanks in advance for your attention and time,
~ Phil
I know just enough VBA to be dangerous, and what I'm attempting is way over my head. I would be grateful for any assistance.
I have a workbook with two sheets named "Tracking" and "Summary". On the Tracking sheet in column A is a number "JobDay" (1 - 5). I want to add the values in Tracking ("M") of each row that has JobDay = 1 in it and paste the sum in Summary ("G4"). I then want to repeat this for JobDay values 2 - 5, pasting the sum in Summary H4, I4, J4, & K4 respectively.
The "JobDay" values in Tracking ("A") will always be grouped together; all the ones in sequential rows, all the twos, etc. The actual range of ones, twos, etc will vary from week to week.
Here's the code I wrote by pulling bits and pieces from other macros and Google before I realized I had no idea how to make this work.
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim JobDay As String, oPut As Long
Dim lRowA As Long, i As Long
Dim wsB As Worksheet
' Select the Data worksheet
Set wsB = ActiveWorkbook.Sheets("Tracking")
wsB.Select
With wsB
' Find the last Row
lRowA = .Cells(.Rows.Count, "A").End(xlUp).Row
' Collect value based on JobDay #
For i = lRowA
JobDay = .Range("A" & i).Value
If JobDay = 1 Then
Range("M").Value + Sheets("Summary").Range("G4") = oPut
oPut = Sheets("Summary").Range("G4").Value
Next i
End With
End Sub
I hope I've explained this clearly enough that it makes sense.
Thanks in advance for your attention and time,
~ Phil