Hi all,
I am currently struggling with writing a macro, where I would like the macro to sum the last column, starting from the 2nd till the last row of that column. The column which needs to be summed up (last column), can start from Column G, but is variable. This means the column could also be column H, I, J, etc. The range of the column which needs to be summed up, is variable as well.
I am relatively new to writing macro's, but I'd like to think I almost got the Sub finished (see below). The only thing I can't figure out is what to write on the ?? as marked below. I am hoping that there is someone who could let me know if I am indeed on the right track or that I am way off, and could help me with creating the correct Sub?
Hopefully my explanation makes sense, if not please let me know, as I am "MRNewGuy" for a reason
Sub Sum()
'
Range("A1").Select
Selection.End(xlToRight).Select
ActiveCell.Offset(1, 0).Select
LastRow = Range("A2").End(xlDown).Row
ActiveCell.Formula = "=SUM(??2:??" & LastRow & ")"
I am currently struggling with writing a macro, where I would like the macro to sum the last column, starting from the 2nd till the last row of that column. The column which needs to be summed up (last column), can start from Column G, but is variable. This means the column could also be column H, I, J, etc. The range of the column which needs to be summed up, is variable as well.
I am relatively new to writing macro's, but I'd like to think I almost got the Sub finished (see below). The only thing I can't figure out is what to write on the ?? as marked below. I am hoping that there is someone who could let me know if I am indeed on the right track or that I am way off, and could help me with creating the correct Sub?
Hopefully my explanation makes sense, if not please let me know, as I am "MRNewGuy" for a reason
Sub Sum()
'
Range("A1").Select
Selection.End(xlToRight).Select
ActiveCell.Offset(1, 0).Select
LastRow = Range("A2").End(xlDown).Row
ActiveCell.Formula = "=SUM(??2:??" & LastRow & ")"