View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Jacob Skaria Jacob Skaria is offline
external usenet poster
 
Posts: 8,520
Default Using variable in formula

Variables should be kept out of the string and combined using &..

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

If this post helps click Yes
---------------
Jacob Skaria


"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?