hercules89
New Member
- Joined
- Jan 24, 2019
- Messages
- 3
Hey, I am working on some VBA macros for work but have ran into some trouble with the auto-sum function...basically I have various data-sets on the same sheet that I need to auto-sum the total for in column K but the problem lies in that there are 3 blank rows between each set of data...I have included below the code that I have got from recording the macro on Excel but this won't be good each day as the number of rows in each data sets will change so I am guessing I need a loop of some kind but I don't know how to write that...any help would be greatly appreciated
Range("K4").Select
Selection.End(xlDown).Select
Range("K83").Select
ActiveCell.FormulaR1C1 = "=SUM(R[-78]C:R[-1]C)"
Range("K84").Select
Selection.End(xlDown).Select
Selection.End(xlDown).Select
Range("K95").Select
ActiveCell.FormulaR1C1 = "=SUM(R[-9]C:R[-1]C)"
Range("K96").Select
Selection.End(xlDown).Select
Range("K99").Select
Selection.End(xlDown).Select
Range("K107").Select
ActiveCell.FormulaR1C1 = "=SUM(R[-9]C:R[-1]C)"
Range("K108").Select
Selection.End(xlDown).Select
Selection.End(xlDown).Select
Range("K163").Select
ActiveCell.FormulaR1C1 = "=SUM(R[-53]C:R[-1]C)"
Range("K164").Select
Selection.End(xlDown).Select
Selection.End(xlDown).Select
Range("K176").Select
ActiveCell.FormulaR1C1 = "=SUM(R[-10]C:R[-1]C)"
Range("K177").Select
Selection.End(xlDown).Select
Thanks
Range("K4").Select
Selection.End(xlDown).Select
Range("K83").Select
ActiveCell.FormulaR1C1 = "=SUM(R[-78]C:R[-1]C)"
Range("K84").Select
Selection.End(xlDown).Select
Selection.End(xlDown).Select
Range("K95").Select
ActiveCell.FormulaR1C1 = "=SUM(R[-9]C:R[-1]C)"
Range("K96").Select
Selection.End(xlDown).Select
Range("K99").Select
Selection.End(xlDown).Select
Range("K107").Select
ActiveCell.FormulaR1C1 = "=SUM(R[-9]C:R[-1]C)"
Range("K108").Select
Selection.End(xlDown).Select
Selection.End(xlDown).Select
Range("K163").Select
ActiveCell.FormulaR1C1 = "=SUM(R[-53]C:R[-1]C)"
Range("K164").Select
Selection.End(xlDown).Select
Selection.End(xlDown).Select
Range("K176").Select
ActiveCell.FormulaR1C1 = "=SUM(R[-10]C:R[-1]C)"
Range("K177").Select
Selection.End(xlDown).Select
Thanks