Strooprover
New Member
- Joined
- Jul 21, 2017
- Messages
- 25
Hi, I've got a list with data based on streetnames in column 2 of ws Data (=straat in dutch) and dates in ws.(cells Lastr, 1). I wanted to sum up the weights that are in Column 3 of Sheets(Data) for each month individualy.
Now I used this macro, but I have to change to smaller then and greater then values for each month. Is there an easier way to do this so I can run my macro at once without having to chance the numbers per month?
Now I used this macro, but I have to change to smaller then and greater then values for each month. Is there an easier way to do this so I can run my macro at once without having to chance the numbers per month?
Code:
Sub permaand()
Dim ws As Worksheet
Dim ws2 As Worksheet
Set ws = Sheets("Data")
Set ws2 = Sheets("Resultaat")
For lrow = 2 To ws2.Range("A" & Rows.Count).End(xlUp).Row
straat = ws2.Cells(lrow, 1).Value
Gewicht = 0
For Lastr = 2 To ws.Range("A" & Rows.Count).End(xlUp).Row
If ws.Cells(Lastr, 2) = straat And ws.Cells(Lastr, 1) > 42917 And ws.Cells(Lastr, 1) < 42948 Then
Gewicht = Gewicht + ws.Cells(Lastr, 3)
End If
Next Lastr
ws2.Cells(lrow, 9) = Gewicht
Next lrow
End Sub