Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 96
Default Using variable in formula

Public Sub test()
hv = Range("aa1")
Cells(i + 5, 23).Offset(step, 0).Formula = "=+RC[-1]*52*hv"
End Sub

Range("aa1") contains the value 269.1. The value in RC[-1] is 3758.7.

The cell in position 5,23++ does not recognize hv as a number but just shows
"hv" with the rest of the formula. How can I fix this?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Using variable in formula

You're using R1C1 reference style. So use .FormulaR1C1.

And you don't need that leading + in the formula:

Cells(i + 5, 23).Offset(step, 0).FormulaR1C1 = "=RC[-1]*52*" & hv



Erik wrote:

Public Sub test()
hv = Range("aa1")
Cells(i + 5, 23).Offset(step, 0).Formula = "=+RC[-1]*52*hv"
End Sub

Range("aa1") contains the value 269.1. The value in RC[-1] is 3758.7.

The cell in position 5,23++ does not recognize hv as a number but just shows
"hv" with the rest of the formula. How can I fix this?


--

Dave Peterson
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
How to get variable from a formula pontitt Excel Programming 4 July 6th 08 09:38 PM
Variable within a formula Tom Melosi Excel Worksheet Functions 4 August 21st 07 04:07 AM
formula containing a formula-dependent variable - how? CompeterN New Users to Excel 1 November 8th 06 02:02 PM
Variable in formula StephanieH Excel Programming 2 January 12th 06 03:10 PM
Help With a Variable Formula jdurrmsu Excel Programming 1 September 16th 05 04:22 PM


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