PC Review


Reply
Thread Tools Rate Thread

cell.formula returns value

 
 
Gleam
Guest
Posts: n/a
 
      18th Dec 2007
I have this line of code:
MyStr = Cells(12 , "D").Formula

I expect it to return "=D11 + D7" but it reurns the the value Cells(12 ,
"D").Value

How do I get the formula?


 
Reply With Quote
 
 
 
 
carlo
Guest
Posts: n/a
 
      18th Dec 2007
Did you try

formulalocal
or
formular1c1
?

maybe one of those work.
Are you sure, that D12 = D11 + D7?

hth

Carlo

On Dec 18, 2:00 pm, Gleam <Gl...@discussions.microsoft.com> wrote:
> I have this line of code:
> MyStr = Cells(12 , "D").Formula
>
> I expect it to return "=D11 + D7" but it reurns the the value Cells(12 ,
> "D").Value
>
> How do I get the formula?


 
Reply With Quote
 
JMB
Guest
Posts: n/a
 
      18th Dec 2007
Since Cells(12,"D") refers to the activesheet, are you sure the sheet
containing the formula "=D11+D7" is the active sheet??

If it is possible the sheet you want may not be the active sheet when the
macro runs, you could fully qualify your reference
Sheets("SheetName").Cells(12, "D").Formula





"Gleam" wrote:

> I have this line of code:
> MyStr = Cells(12 , "D").Formula
>
> I expect it to return "=D11 + D7" but it reurns the the value Cells(12 ,
> "D").Value
>
> How do I get the formula?
>
>

 
Reply With Quote
 
Gleam
Guest
Posts: n/a
 
      18th Dec 2007


"JMB" wrote:

> Since Cells(12,"D") refers to the activesheet, are you sure the sheet
> containing the formula "=D11+D7" is the active sheet??
>
> If it is possible the sheet you want may not be the active sheet when the
> macro runs, you could fully qualify your reference
> Sheets("SheetName").Cells(12, "D").Formula
>
>
>
>
>
> "Gleam" wrote:
>
> > I have this line of code:
> > MyStr = Cells(12 , "D").Formula
> >
> > I expect it to return "=D11 + D7" but it reurns the the value Cells(12 ,
> > "D").Value
> >
> > How do I get the formula?
> >
> >

 
Reply With Quote
 
Gleam
Guest
Posts: n/a
 
      18th Dec 2007
Thank you for the ideas. It turned out that deleting blank rows below the row
in question turned the formula into a value, before it ever got to the bit of
code I posted. I have found another way of acheiving what I wanted when
deleting rows, so problem is resolved. Many thanks.

"JMB" wrote:

> Since Cells(12,"D") refers to the activesheet, are you sure the sheet
> containing the formula "=D11+D7" is the active sheet??
>
> If it is possible the sheet you want may not be the active sheet when the
> macro runs, you could fully qualify your reference
> Sheets("SheetName").Cells(12, "D").Formula
>
>
>
>
>
> "Gleam" wrote:
>
> > I have this line of code:
> > MyStr = Cells(12 , "D").Formula
> >
> > I expect it to return "=D11 + D7" but it reurns the the value Cells(12 ,
> > "D").Value
> >
> > How do I get the formula?
> >
> >

 
Reply With Quote
 
JMB
Guest
Posts: n/a
 
      19th Dec 2007
thanks for posting back and letting us know you found the problem

"Gleam" wrote:

> Thank you for the ideas. It turned out that deleting blank rows below the row
> in question turned the formula into a value, before it ever got to the bit of
> code I posted. I have found another way of acheiving what I wanted when
> deleting rows, so problem is resolved. Many thanks.
>
> "JMB" wrote:
>
> > Since Cells(12,"D") refers to the activesheet, are you sure the sheet
> > containing the formula "=D11+D7" is the active sheet??
> >
> > If it is possible the sheet you want may not be the active sheet when the
> > macro runs, you could fully qualify your reference
> > Sheets("SheetName").Cells(12, "D").Formula
> >
> >
> >
> >
> >
> > "Gleam" wrote:
> >
> > > I have this line of code:
> > > MyStr = Cells(12 , "D").Formula
> > >
> > > I expect it to return "=D11 + D7" but it reurns the the value Cells(12 ,
> > > "D").Value
> > >
> > > How do I get the formula?
> > >
> > >

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Copy cell formula returns zero instead of cell value Dorci Microsoft Excel Discussion 1 8th Mar 2011 06:29 PM
Make cell value zero if cell formula returns value less than zero? Fred Ernst Microsoft Excel Misc 2 20th Feb 2007 04:57 PM
formula for a cell which is blank returns populated cell =?Utf-8?B?R3JhY2V5MQ==?= Microsoft Excel Misc 1 2nd Feb 2007 09:17 AM
Formula returns cell name =?Utf-8?B?cmp2ZWdh?= Microsoft Excel Misc 1 17th Aug 2006 08:36 PM
RE: Formula returns cell name =?Utf-8?B?RGF2ZSBG?= Microsoft Excel Misc 0 17th Aug 2006 08:35 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:12 PM.