Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default ActiveCell.FormulaR1C1

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,327
Default ActiveCell.FormulaR1C1

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
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
ActiveCell.FormulaR1C1 Rick Excel Discussion (Misc queries) 3 March 28th 10 10:36 PM
ActiveCell.FormulaR1C1 = "=SUM(R[-tellerteller]C:R[-1]C)" Jack Sons Excel Discussion (Misc queries) 5 September 29th 09 09:58 PM
Using activecell in vlookup csdjj Excel Discussion (Misc queries) 2 June 25th 09 11:31 PM
If activecell.column = variable then activecell,offset (0,1) Battykoda via OfficeKB.com Excel Discussion (Misc queries) 1 October 2nd 07 08:05 PM
reference to other worksheets in FormulaR1C1 Stefi Excel Discussion (Misc queries) 6 May 25th 05 09:01 AM


All times are GMT +1. The time now is 10:17 PM.

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

About Us

"It's about Microsoft Excel"