Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default change cell value, but keep formula

Hello,
Could someone tell me how to change the value
of a cell, without also changing the formula?
The following code illustrates my problem:

Dim r As Range
Application.EnableEvents = False
Set r = Range("A1")
r.Formula = "= 42 / 100000"
r.Value = "negligible"
MsgBox "r.Formula = " & r.Formula & ", r.Value = " & r.Value
Application.EnableEvents = True

Assignment to the value seems to destroy the formula.

Many thanks,

David Wakeling
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default change cell value, but keep formula

You cannot.

If there is a formula in the cell, then the value is the result of that
formula, they are not independent.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"David Wakeling" wrote in message
om...
Hello,
Could someone tell me how to change the value
of a cell, without also changing the formula?
The following code illustrates my problem:

Dim r As Range
Application.EnableEvents = False
Set r = Range("A1")
r.Formula = "= 42 / 100000"
r.Value = "negligible"
MsgBox "r.Formula = " & r.Formula & ", r.Value = " & r.Value
Application.EnableEvents = True

Assignment to the value seems to destroy the formula.

Many thanks,

David Wakeling



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,253
Default change cell value, but keep formula

yep... the formula evaluates to the value,
setting either destroys the other.

you probably want to set then number format

..NumberFormat = "[<0.1]""negligible"";General"


keepITcool

< email : keepitcool chello nl (with @ and .)
< homepage: http://members.chello.nl/keepitcool


(David Wakeling) wrote:

Hello,
Could someone tell me how to change the value
of a cell, without also changing the formula?
The following code illustrates my problem:

Dim r As Range
Application.EnableEvents = False
Set r = Range("A1")
r.Formula = "= 42 / 100000"
r.Value = "negligible"
MsgBox "r.Formula = " & r.Formula & ", r.Value = " & r.Value
Application.EnableEvents = True

Assignment to the value seems to destroy the formula.

Many thanks,

David Wakeling


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
cell value to change formula Rich[_2_] Excel Discussion (Misc queries) 1 February 24th 09 05:48 AM
copy formula down a column and have cell references change within formula brad New Users to Excel 5 May 13th 07 04:38 PM
How to change a formula in one cell and have these changes appear Sam Excel Worksheet Functions 3 May 18th 05 10:57 PM
How to change a formula in one cell and have these changes appear Duke Carey Excel Worksheet Functions 1 May 17th 05 06:15 PM
change a cell formula JimP Excel Programming 4 November 8th 03 04:43 PM


All times are GMT +1. The time now is 09:46 AM.

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"