ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Macro - formula for end of last row (https://www.excelbanter.com/excel-worksheet-functions/28640-re-macro-formula-end-last-row.html)

Gary Brown

Macro - formula for end of last row
 
This formual would put a SUM formula 2 lines below the end of your data in
Column E. Hope this example helps.
'/==================================/
Range("E" & _
(ActiveSheet.Cells.SpecialCells(xlLastCell).Row _
+ 2)).FormulaLocal = _
"=Sum(E2:E" & _
ActiveSheet.Cells.SpecialCells(xlLastCell).Row & ")"
'/==================================/

--
Gary Brown

Please rate this posting if it is helpful to you.


"JN" wrote:

Hi,

I want to set up a macro to have different formulas on the last row of the
worksheet. Each month, the amount of data is different. This is what the
macro to do:

two rows below the last row of the data, set up formulas in column E, L to
R. Each formula ties to data from the last row.

I tried to set up the macro using selection.end(xlsDown), somehow, I can't
make it to work. Please help. Thanx



JN

Thanks, Gary.

Does that mean I can change anything after the " = Sum" formula? I won't be
using SUM formula. I want to set up a formula to pull data from the last row
"Grand total" and divide it with a constant on the first row.

JN



"Gary Brown" wrote:

This formual would put a SUM formula 2 lines below the end of your data in
Column E. Hope this example helps.
'/==================================/
Range("E" & _
(ActiveSheet.Cells.SpecialCells(xlLastCell).Row _
+ 2)).FormulaLocal = _
"=Sum(E2:E" & _
ActiveSheet.Cells.SpecialCells(xlLastCell).Row & ")"
'/==================================/

--
Gary Brown

Please rate this posting if it is helpful to you.


"JN" wrote:

Hi,

I want to set up a macro to have different formulas on the last row of the
worksheet. Each month, the amount of data is different. This is what the
macro to do:

two rows below the last row of the data, set up formulas in column E, L to
R. Each formula ties to data from the last row.

I tried to set up the macro using selection.end(xlsDown), somehow, I can't
make it to work. Please help. Thanx




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

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