ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   VBA Formula with variable s/b simple (https://www.excelbanter.com/excel-programming/358643-vba-formula-variable-s-b-simple.html)

Bricktop

VBA Formula with variable s/b simple
 
I am trying to sum a column in Excel in my macro. This is what I have so far

Range("C" & LASTROW).formula = "=SUM(Range("C1:C" & lastrow - 1"))"

I've tried several scenerios and just can't figure it out
Any help would be greatly appreciated.




Jim Thomlinson

VBA Formula with variable s/b simple
 
Range("C" & LASTROW).formula = "=SUM(C1:C" & lastrow - 1 & ")"

--
HTH...

Jim Thomlinson


"Bricktop" wrote:

I am trying to sum a column in Excel in my macro. This is what I have so far

Range("C" & LASTROW).formula = "=SUM(Range("C1:C" & lastrow - 1"))"

I've tried several scenerios and just can't figure it out
Any help would be greatly appreciated.




Bricktop

VBA Formula with variable s/b simple
 
Thanks Jim - It worked PERFECT
I new I was close!


"Jim Thomlinson" wrote:

Range("C" & LASTROW).formula = "=SUM(C1:C" & lastrow - 1 & ")"

--
HTH...

Jim Thomlinson


"Bricktop" wrote:

I am trying to sum a column in Excel in my macro. This is what I have so far

Range("C" & LASTROW).formula = "=SUM(Range("C1:C" & lastrow - 1"))"

I've tried several scenerios and just can't figure it out
Any help would be greatly appreciated.





All times are GMT +1. The time now is 01:58 PM.

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