Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi,
I need to sum the values of all cells above my current cell, but my current row changes with each spreadsheet. I recorded a macro and got the following code: ActiveCell.FormulaR1C1 = "=SUM(R[-17]C:R[-1]C)" But the problem is the "-17". In this case I was on row 18--I think-- but next time I'll be on a different row, so this macro won't work. How do I sum all cells from the cell above my current cell to the top row? Thanks, Eric |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Sub Sums()
Dim iEnd As Integer Dim iCol As Integer iCol = ActiveCell.Column iEnd = Cells(1, iCol).End(xlDown).Row Cells(iEnd + 1, iCol).Formula = "=SUM(" & Cells(1, iCol).Address _ & ":" & Cells(iEnd, iCol).Address & ")" End Sub Hth, Merjet |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks, Merjet, your suggest works perfectly!
|
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
change cell values of to reflect most current entry in a range | Excel Worksheet Functions | |||
Replacing Linked Cell Values w/ Current Values | Excel Worksheet Functions | |||
Populating a cell with the current value of a variable | Excel Programming | |||
variable = current cell in VB | Excel Programming | |||
Convert to values, but not at current cell | Excel Programming |