Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,069
Default 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

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 611
Default 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



  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 390
Default 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.

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
Help with Lookup(), VLookup phil Excel Worksheet Functions 6 February 8th 07 01:06 AM
LOOKUP or VLOOKUP MichelleS Excel Worksheet Functions 9 October 20th 06 02:11 PM
Formula using IF? Vlookup? Lookup? I'm not sure. CJ Excel Worksheet Functions 3 September 13th 06 05:27 PM
Lookup without VLOOKUP? J New Users to Excel 6 November 17th 05 06:57 AM
LOOKUP or VLOOKUP Bennie Excel Worksheet Functions 4 March 24th 05 07:45 PM


All times are GMT +1. The time now is 03:30 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"