I'm trying to learn some VBA and in my testing/learning, I'm trying to put the sum total of col A in cell A1 and with this below code Im able to get my answer.
Range("A1") = WorksheetFunction.Sum(Range("A:A"))
However, Im trying to tweak the code such that the data should only check from cell A2 to the last data cell in col A (dynamic - as my no of rows can change) even if there are blank/emply cells or null value cells in between. And using this code, I'm getting an error (see bottom). Any recommendations? Btw this is the only code in my subroutine.
Range("A1") = WorksheetFunction.Sum(Range("A2:A" & lastrow))
Thank you for your suggestions.
Range("A1") = WorksheetFunction.Sum(Range("A:A"))
However, Im trying to tweak the code such that the data should only check from cell A2 to the last data cell in col A (dynamic - as my no of rows can change) even if there are blank/emply cells or null value cells in between. And using this code, I'm getting an error (see bottom). Any recommendations? Btw this is the only code in my subroutine.
Range("A1") = WorksheetFunction.Sum(Range("A2:A" & lastrow))
Thank you for your suggestions.