Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22
Default Mixing Absolute and Relative Reference in a Formula

Hello,
I am trying to mix absolute and relative references in a formula. I am
trying to sum a column who's length changes. One time there may be 20 cells
in the column with data and the next time it might have 50.
I know that the data starts in the same place every time, cell A15. I use a
Do Until loop to find the last cell with data in the column. After I find
the last cell in the the column, I move to the next cell down. My total will
go in this cell. I then want to sum the column, starting in cell A15 to
whatever cell is the last one in the column.
I think I need something like SUM(A15,ActiveCell.Offset(-1,0)).....Is
something like that possible?


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Mixing Absolute and Relative Reference in a Formula

Dim rng as Range
set rng = cells(rows.count,1).End(xlup).Offset(1,0)
rng.FormulaR1C1 = "=Sum(R15C:R[-1]C)"

or

Range("A15").End(xldown).Offset(1,0).formulaR1C1 = _
"=Sum(R15C:R[-1]C)"

--
Regards,
Tom Ogilvy




"tedd13" wrote:

Hello,
I am trying to mix absolute and relative references in a formula. I am
trying to sum a column who's length changes. One time there may be 20 cells
in the column with data and the next time it might have 50.
I know that the data starts in the same place every time, cell A15. I use a
Do Until loop to find the last cell with data in the column. After I find
the last cell in the the column, I move to the next cell down. My total will
go in this cell. I then want to sum the column, starting in cell A15 to
whatever cell is the last one in the column.
I think I need something like SUM(A15,ActiveCell.Offset(-1,0)).....Is
something like that possible?


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default Mixing Absolute and Relative Reference in a Formula

If there are no populated cells below your data:

With Range("A" & Rows.Count).End(xlUp)
.Formula = "=SUM(A15:A" & .Row - 1 & ")"
End With

In article ,
tedd13 wrote:

Hello,
I am trying to mix absolute and relative references in a formula. I am
trying to sum a column who's length changes. One time there may be 20 cells
in the column with data and the next time it might have 50.
I know that the data starts in the same place every time, cell A15. I use a
Do Until loop to find the last cell with data in the column. After I find
the last cell in the the column, I move to the next cell down. My total will
go in this cell. I then want to sum the column, starting in cell A15 to
whatever cell is the last one in the column.
I think I need something like SUM(A15,ActiveCell.Offset(-1,0)).....Is
something like that possible?

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Mixing Absolute and Relative Reference in a Formula

No need to lopp through the cells.

iLastRow = Cells(Rows.Count,"A").End(xlUp).Row
Cells(iLastRow+1,"A").Formula = "=SUM(A15:A" & iLastRow & ")"

--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"tedd13" wrote in message
...
Hello,
I am trying to mix absolute and relative references in a formula. I am
trying to sum a column who's length changes. One time there may be 20

cells
in the column with data and the next time it might have 50.
I know that the data starts in the same place every time, cell A15. I use

a
Do Until loop to find the last cell with data in the column. After I find
the last cell in the the column, I move to the next cell down. My total

will
go in this cell. I then want to sum the column, starting in cell A15 to
whatever cell is the last one in the column.
I think I need something like SUM(A15,ActiveCell.Offset(-1,0)).....Is
something like that possible?




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Mixing Absolute and Relative Reference in a Formula

wouldn't it be

With Range("A" & Rows.Count).End(xlUp)(2)
.Formula = "=SUM(A15:A" & .Row - 1 & ")"
End With


--
Regards,
Tom Ogilvy


"JE McGimpsey" wrote:

If there are no populated cells below your data:

With Range("A" & Rows.Count).End(xlUp)
.Formula = "=SUM(A15:A" & .Row - 1 & ")"
End With

In article ,
tedd13 wrote:

Hello,
I am trying to mix absolute and relative references in a formula. I am
trying to sum a column who's length changes. One time there may be 20 cells
in the column with data and the next time it might have 50.
I know that the data starts in the same place every time, cell A15. I use a
Do Until loop to find the last cell with data in the column. After I find
the last cell in the the column, I move to the next cell down. My total will
go in this cell. I then want to sum the column, starting in cell A15 to
whatever cell is the last one in the column.
I think I need something like SUM(A15,ActiveCell.Offset(-1,0)).....Is
something like that possible?




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default Mixing Absolute and Relative Reference in a Formula

Yup - misread...thanks for the correction.

In article ,
Tom Ogilvy wrote:

wouldn't it be

With Range("A" & Rows.Count).End(xlUp)(2)
.Formula = "=SUM(A15:A" & .Row - 1 & ")"
End With

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Mixing absolute & relative reference Gilbert DE CEULAER Excel Worksheet Functions 3 December 23rd 08 11:54 AM
Absolute or Relative reference - no longer a choice! Ingeniero1[_3_] Excel Programming 5 February 9th 06 01:54 PM
mixing absolute and relative references shellshock[_10_] Excel Programming 2 September 14th 05 08:45 PM
Explanation Relative/Absolute Cell Reference Cath Excel Worksheet Functions 1 March 6th 05 04:10 AM
Combining absolute and relative reference for sum Denise Excel Programming 1 November 4th 04 06:34 AM


All times are GMT +1. The time now is 11:26 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"