Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Setting a formula using VBA

How do I set a cell to be a formula using VBA? I have
tried the following:
PNLWorksheet.Cells(lngDown, 9).Formula = "=" &
PNLWorksheet.Cells(lngDown, 8).Value & "/" &
PNLWorksheet.Cells(lngDenominator, 8)

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Setting a formula using VBA

Phill,
Try this: .FormulaR1C1 = "the formula you want"

HTH
Chris Hoffman

"Phill" wrote in message
...
How do I set a cell to be a formula using VBA? I have
tried the following:
PNLWorksheet.Cells(lngDown, 9).Formula = "=" &
PNLWorksheet.Cells(lngDown, 8).Value & "/" &
PNLWorksheet.Cells(lngDenominator, 8)



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Setting a formula using VBA

Hi,
You can enter a formula in 2 ways :

1. a static formula
Cells(1,1).FormulaLocal = "=" & Cells(1,2) & "/" & Cells(1,3)

2. a dynamic formula
Cells(1,1).FormulaLocal = "=" & Cells(1,2).Address & "/" &
Cells(1,3).Address

I hope this helps


---
Message posted from http://www.ExcelForum.com/

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Setting a formula using VBA

PNLWorksheet.Cells(lngDown, 9).Formula = "=" & _
"Sum(A1:A10)"

should work. If you want to express the formula in R1C1 terms

PNLWorksheet.Cells(lngDown, 9).FormulaR1C1 = "=" & _
"Sum(R1C1:R10C1)"

If you have a version other than English and want to use the same
terminology as would be used manually, then use

FormulaLocal
or
FormulaR1C1Local



--
Regards,
Tom Ogilvy


Phill wrote in message
...
How do I set a cell to be a formula using VBA? I have
tried the following:
PNLWorksheet.Cells(lngDown, 9).Formula = "=" &
PNLWorksheet.Cells(lngDown, 8).Value & "/" &
PNLWorksheet.Cells(lngDenominator, 8)



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
Setting up a formula (when F2<11,000)=$25 Hawkeye Excel Worksheet Functions 3 March 16th 10 03:53 PM
Help with setting up a formula Greggo G[_2_] Excel Discussion (Misc queries) 2 November 25th 09 02:02 PM
Setting up a formula fishingforhelp Excel Worksheet Functions 4 May 3rd 07 09:52 AM
cancelling getpivot formula when setting formula outside pivot ta. cancelling getpivot formula Excel Worksheet Functions 2 October 31st 06 10:31 PM
Setting a value from a formula Mervyn Thomas Excel Programming 1 January 18th 04 10:09 AM


All times are GMT +1. The time now is 07:05 PM.

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"