tonywatsonhelp
Well-known Member
- Joined
- Feb 24, 2014
- Messages
- 3,194
- Office Version
- 365
- 2019
- 2016
- Platform
- Windows
Hi everyone,
I've tried to write a simple macro then put it in a loop, but i've never done my own loops before, I google who and followed the directions as much as posible but have not had any luck,
I think i might be close but as always I'd be here all week trying to figure out what is wrong as i haven't a CLUE?
Please can someone tell me whats done wrong or whats missing?
It would be really hand to have this as i could adapt the loop into many other jobs as well?
Here the code
Please help i think i'm close,
to summaries, the code is trying to Select M1, find blank cell input formula and do it again
Thanks
Tony
I've tried to write a simple macro then put it in a loop, but i've never done my own loops before, I google who and followed the directions as much as posible but have not had any luck,
I think i might be close but as always I'd be here all week trying to figure out what is wrong as i haven't a CLUE?
Please can someone tell me whats done wrong or whats missing?
It would be really hand to have this as i could adapt the loop into many other jobs as well?
Here the code
Code:
Sub SubTotalAll()
Dim xrow As Long
xrow = 2
Dim lastrow As Long
lastrow = Cells(Rows.Count, 1).End(x1Up).Row
Do Until xrow = lastrow + 1
Range("M1").Select
Selection.End(xlDown).Select
ActiveCell.Offset(1, 0).Range("A1").Select
Selection.FormulaR1C1 = "=SUM(R[-24]C:R[-1]C)"
xrow = xrow + 1
Loop
End Sub
Please help i think i'm close,
to summaries, the code is trying to Select M1, find blank cell input formula and do it again
Thanks
Tony