Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Application Worksheet Function Vlookup error

Dear Experts,

I am trying to use a Vlookup in a worksheet_change macro
and am getting an error message when I use the
range_lookup value of FALSE. Can this be used in a macro
or what am I doing wrong. I need to make sure that the
vlookup is an exact match. Here is the code. Thanks in
advance.

Neal

Private Sub Worksheet_Change(ByVal target As Range)
'
' Test input into symbol cell on YF page
'
Application.EnableEvents = False
If target = Range("InputCell") Then 'make target match
specific cell
If IsError(Application.WorksheetFunction.VLookup(Rang e
("InputCell"), Worksheets("Sheet2").Range("A5:B12"), 2,
False)) Then
MsgBox "It is an invalid name"
Range("InputCell").ClearContents
Else
If Not IsError(Range("companyinput")) Then
Range("InputCell").Value = UCase(Range
("InputCell").Value)
'Add the other code from the Macro that moves the cell
to
'the percent cell
Range("percentinput").Select
End If
End If
End If

Application.EnableEvents = True

End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 923
Default Application Worksheet Function Vlookup error

Are there duplicate values in your table? - this will produce an error even
if there is an exact match.
Cheers
Nigel


"Neal" wrote in message
...
Dear Experts,

I am trying to use a Vlookup in a worksheet_change macro
and am getting an error message when I use the
range_lookup value of FALSE. Can this be used in a macro
or what am I doing wrong. I need to make sure that the
vlookup is an exact match. Here is the code. Thanks in
advance.

Neal

Private Sub Worksheet_Change(ByVal target As Range)
'
' Test input into symbol cell on YF page
'
Application.EnableEvents = False
If target = Range("InputCell") Then 'make target match
specific cell
If IsError(Application.WorksheetFunction.VLookup(Rang e
("InputCell"), Worksheets("Sheet2").Range("A5:B12"), 2,
False)) Then
MsgBox "It is an invalid name"
Range("InputCell").ClearContents
Else
If Not IsError(Range("companyinput")) Then
Range("InputCell").Value = UCase(Range
("InputCell").Value)
'Add the other code from the Macro that moves the cell
to
'the percent cell
Range("percentinput").Select
End If
End If
End If

Application.EnableEvents = True

End Sub



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Application Worksheet Function Vlookup error

Neal,

Just use Application.Vlookuup.

Also, you need to put WorksheetFunction on IsError

Private Sub Worksheet_Change(ByVal target As Range)
'
' Test input into symbol cell on YF page
'
Application.EnableEvents = False
If target = Range("InputCell") Then 'make target match specific cell
If WorksheetFunction.IsError(Application.VLookup(Rang e("InputCell"),
Worksheets("Sheet2").Range("A5:B12"), 2, False)) Then
MsgBox "It is an invalid name"
Range("InputCell").ClearContents
Else
If Not WorksheetFunction.IsError(Range("companyinput")) Then
Range("InputCell").Value = UCase(Range("InputCell").Value)
'Add the other code from the Macro that moves the cell to
'the percent cell
Range("percentinput").Select
End If
End If
End If

Application.EnableEvents = True

End Sub


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Neal" wrote in message
...
Dear Experts,

I am trying to use a Vlookup in a worksheet_change macro
and am getting an error message when I use the
range_lookup value of FALSE. Can this be used in a macro
or what am I doing wrong. I need to make sure that the
vlookup is an exact match. Here is the code. Thanks in
advance.

Neal

Private Sub Worksheet_Change(ByVal target As Range)
'
' Test input into symbol cell on YF page
'
Application.EnableEvents = False
If target = Range("InputCell") Then 'make target match
specific cell
If IsError(Application.WorksheetFunction.VLookup(Rang e
("InputCell"), Worksheets("Sheet2").Range("A5:B12"), 2,
False)) Then
MsgBox "It is an invalid name"
Range("InputCell").ClearContents
Else
If Not IsError(Range("companyinput")) Then
Range("InputCell").Value = UCase(Range
("InputCell").Value)
'Add the other code from the Macro that moves the cell
to
'the percent cell
Range("percentinput").Select
End If
End If
End If

Application.EnableEvents = True

End Sub



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Application Worksheet Function Vlookup error

Bob,

Thanks very much for the answer. That is exactly what I
need.

Neal


-----Original Message-----
Neal,

Just use Application.Vlookuup.

Also, you need to put WorksheetFunction on IsError

Private Sub Worksheet_Change(ByVal target As Range)
'
' Test input into symbol cell on YF page
'
Application.EnableEvents = False
If target = Range("InputCell") Then 'make target match

specific cell
If WorksheetFunction.IsError(Application.VLookup(Rang e

("InputCell"),
Worksheets("Sheet2").Range("A5:B12"), 2, False)) Then
MsgBox "It is an invalid name"
Range("InputCell").ClearContents
Else
If Not WorksheetFunction.IsError(Range

("companyinput")) Then
Range("InputCell").Value = UCase(Range

("InputCell").Value)
'Add the other code from the Macro that moves the

cell to
'the percent cell
Range("percentinput").Select
End If
End If
End If

Application.EnableEvents = True

End Sub


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Neal" wrote in

message
...
Dear Experts,

I am trying to use a Vlookup in a worksheet_change macro
and am getting an error message when I use the
range_lookup value of FALSE. Can this be used in a

macro
or what am I doing wrong. I need to make sure that the
vlookup is an exact match. Here is the code. Thanks in
advance.

Neal

Private Sub Worksheet_Change(ByVal target As Range)
'
' Test input into symbol cell on YF page
'
Application.EnableEvents = False
If target = Range("InputCell") Then 'make target match
specific cell
If IsError(Application.WorksheetFunction.VLookup(Rang e
("InputCell"), Worksheets("Sheet2").Range("A5:B12"), 2,
False)) Then
MsgBox "It is an invalid name"
Range("InputCell").ClearContents
Else
If Not IsError(Range("companyinput")) Then
Range("InputCell").Value = UCase(Range
("InputCell").Value)
'Add the other code from the Macro that moves the

cell
to
'the percent cell
Range("percentinput").Select
End If
End If
End If

Application.EnableEvents = True

End Sub



.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Application Worksheet Function Vlookup error

While the worksheetfunction object does support the iserror function used in
Excel, VBA has its own IsError Function applicable to the use of
Application.Vlookup. So the worksheetfunction qualifier is not required in
this case.


? iserror(cvErr(xlErrNA))
True
? worksheetFunction.IsError(cvErr(xlErrNa))
True

--
Regards,
Tom Ogilvy


"Bob Phillips" wrote in message
...
Neal,

Just use Application.Vlookuup.

Also, you need to put WorksheetFunction on IsError

Private Sub Worksheet_Change(ByVal target As Range)
'
' Test input into symbol cell on YF page
'
Application.EnableEvents = False
If target = Range("InputCell") Then 'make target match specific cell
If WorksheetFunction.IsError(Application.VLookup(Rang e("InputCell"),
Worksheets("Sheet2").Range("A5:B12"), 2, False)) Then
MsgBox "It is an invalid name"
Range("InputCell").ClearContents
Else
If Not WorksheetFunction.IsError(Range("companyinput")) Then
Range("InputCell").Value = UCase(Range("InputCell").Value)
'Add the other code from the Macro that moves the cell to
'the percent cell
Range("percentinput").Select
End If
End If
End If

Application.EnableEvents = True

End Sub


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Neal" wrote in message
...
Dear Experts,

I am trying to use a Vlookup in a worksheet_change macro
and am getting an error message when I use the
range_lookup value of FALSE. Can this be used in a macro
or what am I doing wrong. I need to make sure that the
vlookup is an exact match. Here is the code. Thanks in
advance.

Neal

Private Sub Worksheet_Change(ByVal target As Range)
'
' Test input into symbol cell on YF page
'
Application.EnableEvents = False
If target = Range("InputCell") Then 'make target match
specific cell
If IsError(Application.WorksheetFunction.VLookup(Rang e
("InputCell"), Worksheets("Sheet2").Range("A5:B12"), 2,
False)) Then
MsgBox "It is an invalid name"
Range("InputCell").ClearContents
Else
If Not IsError(Range("companyinput")) Then
Range("InputCell").Value = UCase(Range
("InputCell").Value)
'Add the other code from the Macro that moves the cell
to
'the percent cell
Range("percentinput").Select
End If
End If
End If

Application.EnableEvents = True

End Sub





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
#N/A error with VLOOKUP function Amer Excel Worksheet Functions 3 September 27th 09 11:22 AM
VLOOKUP/IF FUNCTION ERROR WHEN PULLING FROM A LIST - Please Help sbickley Excel Discussion (Misc queries) 2 October 24th 08 07:53 PM
Vlookup Function returning #N/A error for two entries rtjeter Excel Discussion (Misc queries) 2 August 2nd 06 04:58 PM
Vlookup & Lookup function error Beginner Excel Worksheet Functions 9 January 11th 05 12:37 AM
Worksheet Function VB code error Bob[_56_] Excel Programming 1 May 12th 04 12:20 AM


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