Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default putting a simple calculation in a field that may change rows


I have the followingf code to put a formula in a cell.

THis code finds where that cell is, but the formula will always refer
to the value in the same column in the second row, MINUS the value in
the same column but two rows above the formula.
with the macro recorder I get the following:

CODE
Range("B:B").Select
Selection.Find(What:="Total Surplus", After:=ActiveCell,
LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext,
_
MatchCase:=False).Offset(0, 2).Activate
ActiveCell.FormulaR1C1 = "=R[-62]C-R[-2]C"


its the R[-62]C and R[[-2]C that I need to make intelligent.

the 62 component needs to be a value frmo the second row

and obviously the -2 bit refers to whatever is in the cell 2 cells
ABOVE the formula.


i'm not sure how to manipulate the FormulaR1C1 property to get the
desired results.
thanks in advance


--
matpj
------------------------------------------------------------------------
matpj's Profile: http://www.excelforum.com/member.php...o&userid=21076
View this thread: http://www.excelforum.com/showthread...hreadid=483141

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default putting a simple calculation in a field that may change rows

ActiveCell.FormulaR1C1 = "=R2C-R[-2]C"

--
Regards,
Tom Ogilvy

"matpj" wrote in
message ...

I have the followingf code to put a formula in a cell.

THis code finds where that cell is, but the formula will always refer
to the value in the same column in the second row, MINUS the value in
the same column but two rows above the formula.
with the macro recorder I get the following:

CODE
Range("B:B").Select
Selection.Find(What:="Total Surplus", After:=ActiveCell,
LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext,
_
MatchCase:=False).Offset(0, 2).Activate
ActiveCell.FormulaR1C1 = "=R[-62]C-R[-2]C"


its the R[-62]C and R[[-2]C that I need to make intelligent.

the 62 component needs to be a value frmo the second row

and obviously the -2 bit refers to whatever is in the cell 2 cells
ABOVE the formula.


i'm not sure how to manipulate the FormulaR1C1 property to get the
desired results.
thanks in advance


--
matpj
------------------------------------------------------------------------
matpj's Profile:

http://www.excelforum.com/member.php...o&userid=21076
View this thread: http://www.excelforum.com/showthread...hreadid=483141



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
Simple calculation where values change to letters? Zuo Excel Worksheet Functions 3 May 3rd 10 11:48 PM
Putting data from columns into rows Pistols14 Excel Discussion (Misc queries) 1 November 27th 07 10:25 AM
Unable to change field settings in calculated field in a pivot tab Mike Excel Discussion (Misc queries) 0 September 25th 06 07:45 PM
Putting the Subject field in SendMail John Wilson Excel Programming 0 August 13th 03 05:52 PM
Putting the Subject field in SendMail Michael[_12_] Excel Programming 0 August 13th 03 05:37 PM


All times are GMT +1. The time now is 01:57 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"