Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default [VBA] how can a Vlookup return the Formula instead of the Value?

Is it possible, using VBA, to get the FORMULA instead of the VALUE of a
cell using a VLOOKUP ?

When I do this in VBA:
result = Application.VLookup(strName, _
Names("t_Feats").RefersToRange, _
Names("index_column").RefersToRange, False)

'result' contains the value form the Vlookup - but I need the FORMULA
that has generated that value - not the value itsef !!

If it's not possible to do this with VLOOKUP, is there another way [in
VBA] to get the formula from a specific cell in the table range? The
vlookup allows me to easily locate the proper cell in the table...

strName : the NAME of the item that is searched (a la VLOOKUP, 1st
parameter)
t_Feats : Named cell representing the table I need to search
index_column : The column where the required information is located

Thanks for your help!
Richard

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default [VBA] how can a Vlookup return the Formula instead of the Value?

Dim res as Variant, rng as Range
Dim rng1 as Range
set rng1 = Names("t_Feats").Columns(1).Cells
res = Application.Match(strName, rng1,0)
if not iserror(res) then
set rng = rng1(res)
msgbox rng.offset(0,Names("index_Column") _
.ReferstoRange.Value - 1).Formula
Else
msgbox strName & " not found"
End Sub

assumes the code you showed actually works.
Names("index_column").RefersToRange should refer to a single cell that has
the column number in t_Feats columns which has the formula you want to
return.

--
Regards,
Tom Ogilvy


"Richard" wrote in message
oups.com...
Is it possible, using VBA, to get the FORMULA instead of the VALUE of a
cell using a VLOOKUP ?

When I do this in VBA:
result = Application.VLookup(strName, _
Names("t_Feats").RefersToRange, _
Names("index_column").RefersToRange, False)

'result' contains the value form the Vlookup - but I need the FORMULA
that has generated that value - not the value itsef !!

If it's not possible to do this with VLOOKUP, is there another way [in
VBA] to get the formula from a specific cell in the table range? The
vlookup allows me to easily locate the proper cell in the table...

strName : the NAME of the item that is searched (a la VLOOKUP, 1st
parameter)
t_Feats : Named cell representing the table I need to search
index_column : The column where the required information is located

Thanks for your help!
Richard



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default how can a Vlookup return the Formula instead of the Value?

Exactly what I needed !!
Thank you very very much !!

Richard

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
Can VLOOKUP return a formula?? Luke M Excel Worksheet Functions 0 August 17th 09 03:18 PM
Can VLOOKUP return a formula?? JP Ronse Excel Worksheet Functions 0 August 17th 09 03:13 PM
Can VLOOKUP return a formula?? NBVC[_166_] Excel Worksheet Functions 0 August 17th 09 01:55 PM
VLOOKUP and return formula JE Excel Worksheet Functions 2 February 8th 09 11:53 PM
Formula to return the row count of a value in Vlookup William G Excel Discussion (Misc queries) 3 February 29th 08 05:41 PM


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

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"