Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Lookup Function in Macro (VBA)

Hi,

I am trying to 'Record a Macro' in the new Excel 2007 that includes the
LOOKUP Function. However, when I finish recording and try to run it, I get
errors. From what I understand, it is because it has a "{" in the formula.
However, that's just how it is entered. (basically, i want it to look in the
specified cell and place the corresponding value in the selected cell)

Does anyone have a solution to this so that the Macro will run?

Thanks.

Here is the idea of the LOOKUP...
=LOOKUP(I2,{"1","3","5"},{"help","this","the"})
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default Lookup Function in Macro (VBA)

All right smart guy,

If you are trying to add the formula to a cell:

ActiveCell.Formula = _
"=LOOKUP(I2,{""1"",""3"",""5""},{""help"",""this"" ,""the""})"

IF you are trying to get the value of that formula:

Dim myVar As String
myVar = Application.WorksheetFunction.Lookup(Range("I2").V alue, _
Array("1", "3", "5"), Array("help", "this", "the"))

Note that the formula is looking for the string value 1 and not the number 1
in cell I2.

HTH,
Bernie
MS Excel MVP



"smartguy0753" wrote in message
...
Hi,

I am trying to 'Record a Macro' in the new Excel 2007 that includes the
LOOKUP Function. However, when I finish recording and try to run it, I get
errors. From what I understand, it is because it has a "{" in the formula.
However, that's just how it is entered. (basically, i want it to look in
the
specified cell and place the corresponding value in the selected cell)

Does anyone have a solution to this so that the Macro will run?

Thanks.

Here is the idea of the LOOKUP...
=LOOKUP(I2,{"1","3","5"},{"help","this","the"})


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default Lookup Function in Macro (VBA)

Somthing like this...Try and feedback..

Dim arrLookup As Variant
Dim arrResult As Variant

arrLookup = Array("1", "3", "5")
arrResult = Array("help", "this", "the")
MsgBox WorksheetFunction.Lookup("5", arrLookup, arrResult)


If this post helps click Yes
---------------
Jacob Skaria


"smartguy0753" wrote:

Hi,

I am trying to 'Record a Macro' in the new Excel 2007 that includes the
LOOKUP Function. However, when I finish recording and try to run it, I get
errors. From what I understand, it is because it has a "{" in the formula.
However, that's just how it is entered. (basically, i want it to look in the
specified cell and place the corresponding value in the selected cell)

Does anyone have a solution to this so that the Macro will run?

Thanks.

Here is the idea of the LOOKUP...
=LOOKUP(I2,{"1","3","5"},{"help","this","the"})

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
LOOKUP FUNCTION? (LOOKUP VALUE BEING A TIME RENERATED FROM A FORMU JCC Excel Discussion (Misc queries) 5 June 26th 09 09:15 PM
macro to lookup value and open tab based on lookup value brandyvine Excel Programming 3 December 16th 08 09:57 AM
Macro Required for Lookup Function Akash Excel Programming 3 February 23rd 07 06:58 AM
Pivot table doing a lookup without using the lookup function? NGASGELI Excel Discussion (Misc queries) 0 August 2nd 05 05:08 AM
LOOKUP function in VB Macro. Art Du Rea Excel Programming 1 October 13th 03 09:23 PM


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

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

About Us

"It's about Microsoft Excel"