We have a spreadsheet at our company to track hours. It has a column for hours spent on a given project per week and total hours for the project. Each project has a row. Every Monday I manually add the number of hours from last week to the total hours column. I'd like to automate this. I am attempting to loop through column J and, if there is a number in J, add it to K. Then clear cell J (I haven't added this part into the below code, yet). J can be blank, or have non-numeric values, these should be skipped. J will never go past J500.
This is my code, it appears to just loop the currently selected row 500 times in "Megan in Progress" rather than moving from J1 through J500. Could someone help point me towards what I'm doing wrong? Thank you.
Sub UpdateTotals()
Sheets("Megan In Progress").Activate
For Each cell In Sheets("Megan In Progress").Range("J1:J500")
Dim weekVal As Double
If IsNumeric(cell) = True Then
weekVal = cell.Value
ActiveCell.Offset(0, 1).Select
ActiveCell.Value = ActiveCell.Value + weekVal
ActiveCell.Offset(0, -1).Select
End If
Next
End Sub
before macro
after macro