ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Autosum variable range in macro (https://www.excelbanter.com/excel-programming/276018-re-autosum-variable-range-macro.html)

Jeffrey Marcellus

Autosum variable range in macro
 
Eric, you could try something like the following. The only requirement is
that cells in the list are nonblank.
--
ActiveCell.Value = "=sum(" & ActiveCell.Offset(-1, 0).End(xlUp).Address &
":" & ActiveCell.Offset(-1, 0).Address & ")"
--
Good luck,
Jeff

"Eric Dreshfield" wrote in message
...
I would like to be able to add programming to a macro that
mimics the AutoSum key....for example, if cells A1 through
A10 have values and the active cell is A11, I want the
macro to create the =Sum(a1:a10) formula, but I do not
want the cell references hard coded, as the number of rows
will vary each time this process is run. Any suggestions ?

Thanks !




Eric Dreshfield

Autosum variable range in macro
 
Jeff,

Thanks ! That works exactly like I had hoped !

-----Original Message-----
Eric, you could try something like the following. The

only requirement is
that cells in the list are nonblank.
--
ActiveCell.Value = "=sum(" & ActiveCell.Offset(-1, 0).End

(xlUp).Address &
":" & ActiveCell.Offset(-1, 0).Address & ")"
--
Good luck,
Jeff

"Eric Dreshfield" wrote in message
...
I would like to be able to add programming to a macro

that
mimics the AutoSum key....for example, if cells A1

through
A10 have values and the active cell is A11, I want the
macro to create the =Sum(a1:a10) formula, but I do not
want the cell references hard coded, as the number of

rows
will vary each time this process is run. Any

suggestions ?

Thanks !



.



All times are GMT +1. The time now is 02:14 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com