Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi
Does anyone know how to write this code correctly in Excel VBA: Number=15 This will work: ActiveCell.FormulaR1C1 = "=15*R[-2]C" but how to make this work: ActiveCell.FormulaR1C1 = "=Val(Number)*R[-2]C" I have tried with & and " and I can not find a way to do it Regards Leif For E-mail: Substitute lablab with lab. |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Dav Leif
It depends on what datatype Number is declared as -you don't need Val if it's a number format. Try these: Sub test1() Dim Number As Long Number = 15 ActiveCell.FormulaR1C1 = "=" & Number & "*R[-2]C" End Sub Sub test2() Dim Number As String Number = "15" ActiveCell.FormulaR1C1 = "=" & Val(Number) & "*R[-2]C" End Sub -- HTH. Best wishes Harald Followup to newsgroup only please "Leif Rasmussen" skrev i melding ... Hi Does anyone know how to write this code correctly in Excel VBA: Number=15 This will work: ActiveCell.FormulaR1C1 = "=15*R[-2]C" but how to make this work: ActiveCell.FormulaR1C1 = "=Val(Number)*R[-2]C" I have tried with & and " and I can not find a way to do it Regards Leif For E-mail: Substitute lablab with lab. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
ActiveCell.FormulaR1C1 | Excel Discussion (Misc queries) | |||
ActiveCell.FormulaR1C1 = "=SUM(R[-tellerteller]C:R[-1]C)" | Excel Discussion (Misc queries) | |||
Using activecell in vlookup | Excel Discussion (Misc queries) | |||
If activecell.column = variable then activecell,offset (0,1) | Excel Discussion (Misc queries) | |||
reference to other worksheets in FormulaR1C1 | Excel Discussion (Misc queries) |