I have two columns in a table, let's say a and b. The value of the cells in a, when the macro is implemented, will be a = a + b. After the addition is performed, all the values in column b will be set to 0.
I've tried using a for loop to loop through every cell in the columns and adding the values but nothing happens.
Sub zeroAndAdd0_Click()
For i = 2 To NumRows
Cells(i, 4).Value = WorksheetFunction.Sum(Cells(i, 4).Value, Cells(i,5).Value)
Next i
End Sub
No error message occurs but nothing actually happens when I test it.
NumRows?Forloop, set yourNumRowsvariable (currently it's not set so your loop isn't looping anything).NumRows = 10. Then you should see some magic happening. I just guessed at10though so you'll need to set that to whatever makes sense for your sheet. Once that is working then you may want to figure out how to dynamically setNumRowsto the last occupied row in one of these columns.