![]() |
using vlookup to lookup a formula
I trying a use the vlookup function to look up a couple set of formulas used
to calculate the cost of my list of items. How Can I get the vlookup to read the formula and not the value of the formula? If it helps here is one of the formulas if it helps =IF(AQ28,AQ2/4-1,IF(AQ2=1,-2,IF(AQ2=2, 1,IF(AQ2=4,0,IF(AQ2=8,1,"Invalid")))))+$A$4 |
using vlookup to lookup a formula
John,
Here's a UDF that will return the formula in a cell. Put this in a regular module: Function GetFormula(MyCell As Range) As String GetFormula = MyCell.Formula End Function Call it in your cell with =GetFormula(A1) I don't think you can wrap it around your VLOOKUP as VLOOKUP returns a value, not a reference. But you could wrap it around a MATCH wrapped around an INDEX, which functions like VLOOKUP: =GetFormula(INDEX(F1:F5,MATCH(B4,E1:E5,0))) Here the table is E1:F5, and it's looking down the E column for what's in B4. It will return the formula in F1:F5. -- Earl Kiosterud www.smokeylake.com Note: Top-posting has been the norm here. Some folks prefer bottom-posting. But if you bottom-post to a reply that's already top-posted, the thread gets messy. When in Rome... ----------------------------------------------------------------------- "john" wrote in message ... I trying a use the vlookup function to look up a couple set of formulas used to calculate the cost of my list of items. How Can I get the vlookup to read the formula and not the value of the formula? If it helps here is one of the formulas if it helps =IF(AQ28,AQ2/4-1,IF(AQ2=1,-2,IF(AQ2=2, 1,IF(AQ2=4,0,IF(AQ2=8,1,"Invalid")))))+$A$4 |
using vlookup to lookup a formula
In , Earl Kiosterud
spake thusly: Here's a UDF that will return the formula in a cell. Put this in a regular module: Function GetFormula(MyCell As Range) As String GetFormula = MyCell.Formula End Function Call it in your cell with =GetFormula(A1) Very helpful, Earl! (Where were you when I asked a vaguely similar question last month?) :-) I will have use for your UDF. =dman= ================== I don't think you can wrap it around your VLOOKUP as VLOOKUP returns a value, not a reference. But you could wrap it around a MATCH wrapped around an INDEX, which functions like VLOOKUP: =GetFormula(INDEX(F1:F5,MATCH(B4,E1:E5,0))) Here the table is E1:F5, and it's looking down the E column for what's in B4. It will return the formula in F1:F5. |
All times are GMT +1. The time now is 06:42 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com