ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Extracting formula instead of result from cell (https://www.excelbanter.com/excel-programming/348274-extracting-formula-instead-result-cell.html)

Rowan Drummond[_3_]

Extracting formula instead of result from cell
 
Try:

Debug.Print Range("A1").Formula

Hope this helps
Rowan

lithium81 wrote:
Hi,

Is it possible to get the forumla from a cell instead of a the result
of the forumla using VBA/Macros?

e.g. In cell A1 I have the formula B1+C1.

I want to retrieve this formula and furthermore it wud be great if I
could get the values in B1 and C1, but I think once the formula can be
extracted, the rest will be easy.

Thanks!!



lithium81[_4_]

Extracting formula instead of result from cell
 

Hi,

Is it possible to get the forumla from a cell instead of a the result
of the forumla using VBA/Macros?

e.g. In cell A1 I have the formula B1+C1.

I want to retrieve this formula and furthermore it wud be great if I
could get the values in B1 and C1, but I think once the formula can be
extracted, the rest will be easy.

Thanks!!


--
lithium81
------------------------------------------------------------------------
lithium81's Profile: http://www.excelforum.com/member.php...o&userid=29461
View this thread: http://www.excelforum.com/showthread...hreadid=494029


Rowan Drummond[_3_]

Extracting formula instead of result from cell
 
If you want it in a variable then:

dim strFml as string
strFml = range("A1").formula

Regards
Rowan

lithium81 wrote:
Hi,

Thanks! When I do the debug.print, I don't see any output, perhaps I am
using it the wrong way. Could someone help please?

Will this put the data into a variable?

Thanks!



lithium81[_5_]

Extracting formula instead of result from cell
 

Hi,

Thanks! When I do the debug.print, I don't see any output, perhaps I am
using it the wrong way. Could someone help please?

Will this put the data into a variable?

Thanks!


--
lithium81
------------------------------------------------------------------------
lithium81's Profile: http://www.excelforum.com/member.php...o&userid=29461
View this thread: http://www.excelforum.com/showthread...hreadid=494029


lithium81[_6_]

Extracting formula instead of result from cell
 

Thank you! That works great!


--
lithium81
------------------------------------------------------------------------
lithium81's Profile: http://www.excelforum.com/member.php...o&userid=29461
View this thread: http://www.excelforum.com/showthread...hreadid=494029


Rowan Drummond[_3_]

Extracting formula instead of result from cell
 
You're welcome.

lithium81 wrote:
Thank you! That works great!



David McRitchie

Extracting formula instead of result from cell
 
Hi lithium81,
Debug statement results from VBA code appear on the Intermediate
window in the Visual Basic Editor (Ctrl+G).

For what you want I would suggest the use and flexibility of a
User Defined Function see GetFormula at
http://www.mvps.org/dmcritchie/excel...htm#getformula
if it is not obvious where the formula referenced actually is at,
then a variation GetFormulaD might work better for you.
---
HTH,
David McRitchie, Microsoft MVP - Excel [site changed Nov. 2001]
My Excel Pages: http://www.mvps.org/dmcritchie/excel/excel.htm
Search Page: http://www.mvps.org/dmcritchie/excel/search.htm

"Rowan Drummond" wrote in message ...
If you want it in a variable then:

dim strFml as string
strFml = range("A1").formula

Regards
Rowan

lithium81 wrote:
Hi,

Thanks! When I do the debug.print, I don't see any output, perhaps I am
using it the wrong way. Could someone help please?

Will this put the data into a variable?

Thanks!






All times are GMT +1. The time now is 02:40 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com