#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default Lookup

I was given this piece of code by an MVP, and I think I am missing a
reference.

dim res as variant
res =
application.lookup(LEFT(range(D5"),3,range("HTC!A2 :A200"),range("HTC!b2:B200
"))

I don't get the lookup option after typing in application.

Please advise.


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,080
Default Lookup

Type it in manually; it should work. Worksheet functions are now accessed
through the WorksheetFunction object rather than the Application object,
although the latter still works for backward compatibility. Many experts
still prefer to use the Application object as it has some esoteric
advantages.

--

Vasant

"Dthmtlgod" wrote in message
...
I was given this piece of code by an MVP, and I think I am missing a
reference.

dim res as variant
res =

application.lookup(LEFT(range(D5"),3,range("HTC!A2 :A200"),range("HTC!b2:B200
"))

I don't get the lookup option after typing in application.

Please advise.




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default Lookup

Thank you Vasant


"Vasant Nanavati" <vasantn *AT* aol *DOT* com wrote in message
...
Type it in manually; it should work. Worksheet functions are now accessed
through the WorksheetFunction object rather than the Application object,
although the latter still works for backward compatibility. Many experts
still prefer to use the Application object as it has some esoteric
advantages.

--

Vasant

"Dthmtlgod" wrote in message
...
I was given this piece of code by an MVP, and I think I am missing a
reference.

dim res as variant
res =


application.lookup(LEFT(range(D5"),3,range("HTC!A2 :A200"),range("HTC!b2:B200
"))

I don't get the lookup option after typing in application.

Please advise.






  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 770
Default Lookup

You are missing a double quote before D5 and a right paren.

I think it should be
(LEFT(range("D5"),3),range("HTC!A2:A200"),range("H TC!b2:B200"))

hth,

Doug

"Dthmtlgod" wrote in message
...
I was given this piece of code by an MVP, and I think I am missing a
reference.

dim res as variant
res =

application.lookup(LEFT(range(D5"),3,range("HTC!A2 :A200"),range("HTC!b2:B200
"))

I don't get the lookup option after typing in application.

Please advise.




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Lookup

Looks like one of use hosed it up - since you are missing a parentheses and
a quote.

It should be

dim res as variant
res =
application.lookup(LEFT(range("D5"),3), _
range("HTC!A2:A200"),range("HTC!b2:B200"))
if not iserror(res) then
msgbox res
else
msgbox "No match"
End if

the reason application is used is because it doesn't raise a vba error when
the match is not made and it works consistently, where at least in xl97,
some of the lookup and match functions would not work when using
Worksheetfunction. This may have been fixed in later verions.

But as Vasant said, if you want intellisense, then you have to use
worksheettfunction.

--
Regards,
Tom Ogilvy




"Dthmtlgod" wrote in message
...
Thank you Vasant


"Vasant Nanavati" <vasantn *AT* aol *DOT* com wrote in message
...
Type it in manually; it should work. Worksheet functions are now

accessed
through the WorksheetFunction object rather than the Application object,
although the latter still works for backward compatibility. Many experts
still prefer to use the Application object as it has some esoteric
advantages.

--

Vasant

"Dthmtlgod" wrote in message
...
I was given this piece of code by an MVP, and I think I am missing a
reference.

dim res as variant
res =



application.lookup(LEFT(range(D5"),3,range("HTC!A2 :A200"),range("HTC!b2:B200
"))

I don't get the lookup option after typing in application.

Please advise.










  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default Lookup

It was probably me, it is not performing the LOOKUP. I am not sure why, it
is not erroring out though.

Here is the code. Any ideas? I have Res as Variant

z = 5
Do While Range("DCI!A" & z).Value = Date
If CStr(Range("DCI!J" & z).Value) = "000" Then
Res = Application.Lookup(Left(CStr(Range("DCI!D" & z)), 3),
Range("HTC!$A$2:$A$200"), Range("HTC!$B$2:$B$200"))
If Not IsError(Res) Then
Range("DCI!J" & z).Value = Res
Else
Range("DCI!J" & z).Value = "Not Found-" & Res
End If
End If
z = z + 1
Loop


"Tom Ogilvy" wrote in message
...
Looks like one of use hosed it up - since you are missing a parentheses

and
a quote.

It should be

dim res as variant
res =
application.lookup(LEFT(range("D5"),3), _
range("HTC!A2:A200"),range("HTC!b2:B200"))
if not iserror(res) then
msgbox res
else
msgbox "No match"
End if

the reason application is used is because it doesn't raise a vba error

when
the match is not made and it works consistently, where at least in xl97,
some of the lookup and match functions would not work when using
Worksheetfunction. This may have been fixed in later verions.

But as Vasant said, if you want intellisense, then you have to use
worksheettfunction.

--
Regards,
Tom Ogilvy




"Dthmtlgod" wrote in message
...
Thank you Vasant


"Vasant Nanavati" <vasantn *AT* aol *DOT* com wrote in message
...
Type it in manually; it should work. Worksheet functions are now

accessed
through the WorksheetFunction object rather than the Application

object,
although the latter still works for backward compatibility. Many

experts
still prefer to use the Application object as it has some esoteric
advantages.

--

Vasant

"Dthmtlgod" wrote in message
...
I was given this piece of code by an MVP, and I think I am missing a
reference.

dim res as variant
res =




application.lookup(LEFT(range(D5"),3,range("HTC!A2 :A200"),range("HTC!b2:B200
"))

I don't get the lookup option after typing in application.

Please advise.










  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Lookup

I would try it with the formula in a cell and see if it works

=Lookup(Left(DCI!D5,3),HTC!$A$2:$A$200,HTC!$B$2:$B $200)

If it works there, then it should work in your code.

Also, make sure the Left(DCI!D5,3) is returning what you think it should
(when using code)

Sub Tester9()
z = 5
msgbox Left(CStr(Range("DCI!D" & z)), 3)
End Sub

if you are trying to get the first three letters of a month and the cell
contains a date, you may need to use
Sub Tester9()
z = 5
msgbox Left(Range("DCI!D" & z).Text, 3)
End Sub
--
Regards,
Tom Ogilvy



"Dthmtlgod" wrote in message
...
It was probably me, it is not performing the LOOKUP. I am not sure why,

it
is not erroring out though.

Here is the code. Any ideas? I have Res as Variant

z = 5
Do While Range("DCI!A" & z).Value = Date
If CStr(Range("DCI!J" & z).Value) = "000" Then
Res = Application.Lookup(Left(CStr(Range("DCI!D" & z)), 3),
Range("HTC!$A$2:$A$200"), Range("HTC!$B$2:$B$200"))
If Not IsError(Res) Then
Range("DCI!J" & z).Value = Res
Else
Range("DCI!J" & z).Value = "Not Found-" & Res
End If
End If
z = z + 1
Loop


"Tom Ogilvy" wrote in message
...
Looks like one of use hosed it up - since you are missing a parentheses

and
a quote.

It should be

dim res as variant
res =
application.lookup(LEFT(range("D5"),3), _
range("HTC!A2:A200"),range("HTC!b2:B200"))
if not iserror(res) then
msgbox res
else
msgbox "No match"
End if

the reason application is used is because it doesn't raise a vba error

when
the match is not made and it works consistently, where at least in xl97,
some of the lookup and match functions would not work when using
Worksheetfunction. This may have been fixed in later verions.

But as Vasant said, if you want intellisense, then you have to use
worksheettfunction.

--
Regards,
Tom Ogilvy




"Dthmtlgod" wrote in message
...
Thank you Vasant


"Vasant Nanavati" <vasantn *AT* aol *DOT* com wrote in message
...
Type it in manually; it should work. Worksheet functions are now

accessed
through the WorksheetFunction object rather than the Application

object,
although the latter still works for backward compatibility. Many

experts
still prefer to use the Application object as it has some esoteric
advantages.

--

Vasant

"Dthmtlgod" wrote in message
...
I was given this piece of code by an MVP, and I think I am missing

a
reference.

dim res as variant
res =





application.lookup(LEFT(range(D5"),3,range("HTC!A2 :A200"),range("HTC!b2:B200
"))

I don't get the lookup option after typing in application.

Please advise.












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 help. lookup result based on data in 2 columns lcc Excel Worksheet Functions 3 April 6th 10 01:20 PM
LOOKUP FUNCTION? (LOOKUP VALUE BEING A TIME RENERATED FROM A FORMU JCC Excel Discussion (Misc queries) 5 June 26th 09 09:15 PM
Lookup looks to the prior column if zero appears in the lookup col kenbquik Excel Discussion (Misc queries) 2 March 12th 09 03:41 AM
Join 2 Lists - Lookup value in 1 list & use result in 2nd lookup JBush Excel Worksheet Functions 3 January 3rd 07 11:14 PM
Sumproduct - Condition based on lookup of a Lookup Hari Excel Discussion (Misc queries) 12 May 31st 06 09:28 AM


All times are GMT +1. The time now is 05:14 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"