cell.formula returns value

  • Thread starter Thread starter Gleam
  • Start date Start date
G

Gleam

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?
 
Did you try

formulalocal
or
formular1c1
?

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

hth

Carlo
 
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
 
JMB said:
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
 
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top