Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default translating worksheet formula into VBA


hey all

Could someone please help me with inserting a formula into VBA code?

My formula is :

= IF(C4="",A3,IF(ISNUMBER(VALUE(C4)),C4,A3))

I tried to translate it into my VBA but failed:

Range("A4").Select
ActiveCell.FormulaR1C1 =
"=if(RC[0,3]="",RC[-1,0],if(ISNUMBER(VALUE(RC[0,3])),RC[0,3],RC[-1,0]}}"

Any help appreciated.

Thanks


--
dabith
------------------------------------------------------------------------
dabith's Profile: http://www.excelforum.com/member.php...o&userid=10566
View this thread: http://www.excelforum.com/showthread...hreadid=278086

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 134
Default translating worksheet formula into VBA

Hi,

try this procedure to have all information on the activecell

Sub Info_Cell()

Dim vCell As Range
Dim vMsg As String

Set vCell = ActiveCell

vMsg = vCell.Address & " = " & vCell.Value & "<" & vbCr
vMsg = vMsg & "Cell = R" & vCell.Row & "C" & vCell.Column & "<" & vbCr
vMsg = vMsg & "Value = " & vCell.Value & "<" & vbCr
vMsg = vMsg & "Formula = " & vCell.Formula & "<" & vbCr
vMsg = vMsg & "FormulaR1C1 = " & vCell.FormulaR1C1 & "<" & vbCr

MsgBox vMsg

End Sub

You can assign a userkey to this procedure and execute each time you want to
have the contents, formula or formulaR1C1

Greetings
Jos Vens


"dabith" schreef in bericht
...

hey all

Could someone please help me with inserting a formula into VBA code?

My formula is :

= IF(C4="",A3,IF(ISNUMBER(VALUE(C4)),C4,A3))

I tried to translate it into my VBA but failed:

Range("A4").Select
ActiveCell.FormulaR1C1 =
"=if(RC[0,3]="",RC[-1,0],if(ISNUMBER(VALUE(RC[0,3])),RC[0,3],RC[-1,0]}}"

Any help appreciated.

Thanks


--
dabith
------------------------------------------------------------------------
dabith's Profile:
http://www.excelforum.com/member.php...o&userid=10566
View this thread: http://www.excelforum.com/showthread...hreadid=278086



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 690
Default translating worksheet formula into VBA

Hello. The quotes within the string I believe needed to be double quotes.
Here are four options...

Range("A4").Formula = "=IF(C4="""",A3,IF(ISNUMBER(VALUE(C4)),C4,A3)) "

Range("A4").Formula = "=IF(ISBLANK(C4),A3,IF(ISNUMBER(VALUE(C4)),C4,A3)) "

Range("A4").FormulaR1C1 =
"=IF(RC[2]="""",R[-1]C,IF(ISNUMBER(VALUE(RC[2])),RC[2],R[-1]C))"

Range("A4").FormulaR1C1 =
"=IF(ISBLANK(RC[2]),R[-1]C,IF(ISNUMBER(VALUE(RC[2])),RC[2],R[-1]C))"

HTH :)
--
Dana DeLouis
Win XP & Office 2003


"dabith" wrote in message
...

hey all

Could someone please help me with inserting a formula into VBA code?

My formula is :

= IF(C4="",A3,IF(ISNUMBER(VALUE(C4)),C4,A3))

I tried to translate it into my VBA but failed:

Range("A4").Select
ActiveCell.FormulaR1C1 =
"=if(RC[0,3]="",RC[-1,0],if(ISNUMBER(VALUE(RC[0,3])),RC[0,3],RC[-1,0]}}"

Any help appreciated.

Thanks


--
dabith
------------------------------------------------------------------------
dabith's Profile:
http://www.excelforum.com/member.php...o&userid=10566
View this thread: http://www.excelforum.com/showthread...hreadid=278086



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
Translating Erika Excel Discussion (Misc queries) 0 June 6th 08 03:13 PM
Translating formulas Cameron Excel Discussion (Misc queries) 9 August 3rd 06 11:43 AM
Translating an IF formula from Lotus 1-2-3 to Excel fsufan13 Excel Worksheet Functions 6 November 4th 05 12:34 AM
Translating spreadsheet formula to VBA Sheela[_2_] Excel Programming 8 June 6th 05 02:51 AM
Overflow when translating from C++ HELP!! hunting Excel Programming 6 April 24th 04 08:18 PM


All times are GMT +1. The time now is 11:18 AM.

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"