Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 31
Default Application.WorksheetFunctions

Hello,

I am recieving Error 2015 when I call VLookUp, anyone have any ideas why?
TIA

Lookup Table Named Range "TestLookUp"

Test Lookup
Key Value
1 Value1
2 Value2
3 Value3
4 Value4

private mChanging as boolean

Private Sub Worksheet_Change(ByVal Target As Range)

If mChanging then exit sub
If Target.Address < "$B$1" then exit sub

mChanging = true

Dim sNamedRange as string
sNamedRange = replace(ActiveWorkbook.Names("TestLookUp").RefersT o,"=","")
If Not Application.IsError(Application.VLookup(Target.Val ue,
sNamedRange, 2, False)) Then
If Not
Application.WorksheetFunction.IsNA(Application.VLo okup(Target.Value,
sNamedRange, 2)) Then
Target.Worksheet.Range("$A$1").Formula = "VLOOKUP(""" &
target.address & """,""TestLookUp"",2)"
Else
Target.Worksheet.Range("$A$1").Formula = ""
Target.Worksheet.Range("$A$1").Value = ""
End If
End If

mChanging = false

End Sub


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 31
Default Application.WorksheetFunctions

This seems to work

Application.VLookup(cint(target.value),
ActiveWorkbook.ActiveSheet.range("TestLookUp"), 2,false)


"AMDRIT" wrote in message
...
Hello,

I am recieving Error 2015 when I call VLookUp, anyone have any ideas why?
TIA

Lookup Table Named Range "TestLookUp"

Test Lookup
Key Value
1 Value1
2 Value2
3 Value3
4 Value4

private mChanging as boolean

Private Sub Worksheet_Change(ByVal Target As Range)

If mChanging then exit sub
If Target.Address < "$B$1" then exit sub

mChanging = true

Dim sNamedRange as string
sNamedRange =
replace(ActiveWorkbook.Names("TestLookUp").RefersT o,"=","")
If Not Application.IsError(Application.VLookup(Target.Val ue,
sNamedRange, 2, False)) Then
If Not
Application.WorksheetFunction.IsNA(Application.VLo okup(Target.Value,
sNamedRange, 2)) Then
Target.Worksheet.Range("$A$1").Formula = "VLOOKUP(""" &
target.address & """,""TestLookUp"",2)"
Else
Target.Worksheet.Range("$A$1").Formula = ""
Target.Worksheet.Range("$A$1").Value = ""
End If
End If

mChanging = false

End Sub



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

Vlookup expects the lookup table as arange, not a string, so maybe

Application.VLookup(Target.Value, Range(sNamedRange), 2, False)

--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"AMDRIT" wrote in message
...
Hello,

I am recieving Error 2015 when I call VLookUp, anyone have any ideas why?
TIA

Lookup Table Named Range "TestLookUp"

Test Lookup
Key Value
1 Value1
2 Value2
3 Value3
4 Value4

private mChanging as boolean

Private Sub Worksheet_Change(ByVal Target As Range)

If mChanging then exit sub
If Target.Address < "$B$1" then exit sub

mChanging = true

Dim sNamedRange as string
sNamedRange =

replace(ActiveWorkbook.Names("TestLookUp").RefersT o,"=","")
If Not Application.IsError(Application.VLookup(Target.Val ue,
sNamedRange, 2, False)) Then
If Not
Application.WorksheetFunction.IsNA(Application.VLo okup(Target.Value,
sNamedRange, 2)) Then
Target.Worksheet.Range("$A$1").Formula = "VLOOKUP(""" &
target.address & """,""TestLookUp"",2)"
Else
Target.Worksheet.Range("$A$1").Formula = ""
Target.Worksheet.Range("$A$1").Value = ""
End If
End If

mChanging = false

End Sub




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 31
Default Application.WorksheetFunctions

This works better:

dim result as variant

result = Application.VLookup(CInt(Target.Value),
ActiveWorkbook.Names("TestLookUp").RefersToRange, 2, False)

If Not Application.IsError(result) And Not Application.IsNA(result) Then
Target.Worksheet.Range("$A$1").Formula = "=VLOOKUP(""" & target.address &
""",TestLookUp,2)"
Else
Target.Worksheet.Range("$A$1").Clear
End If


"AMDRIT" wrote in message
...
Hello,

I am recieving Error 2015 when I call VLookUp, anyone have any ideas why?
TIA

Lookup Table Named Range "TestLookUp"

Test Lookup
Key Value
1 Value1
2 Value2
3 Value3
4 Value4

private mChanging as boolean

Private Sub Worksheet_Change(ByVal Target As Range)

If mChanging then exit sub
If Target.Address < "$B$1" then exit sub

mChanging = true

Dim sNamedRange as string
sNamedRange =
replace(ActiveWorkbook.Names("TestLookUp").RefersT o,"=","")
If Not Application.IsError(Application.VLookup(Target.Val ue,
sNamedRange, 2, False)) Then
If Not
Application.WorksheetFunction.IsNA(Application.VLo okup(Target.Value,
sNamedRange, 2)) Then
Target.Worksheet.Range("$A$1").Formula = "VLOOKUP(""" &
target.address & """,""TestLookUp"",2)"
Else
Target.Worksheet.Range("$A$1").Formula = ""
Target.Worksheet.Range("$A$1").Value = ""
End If
End If

mChanging = false

End Sub



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 31
Default Application.WorksheetFunctions

You were correct, thanks a lot.

"Bob Phillips" wrote in message
...
Vlookup expects the lookup table as arange, not a string, so maybe

Application.VLookup(Target.Value, Range(sNamedRange), 2, False)

--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"AMDRIT" wrote in message
...
Hello,

I am recieving Error 2015 when I call VLookUp, anyone have any ideas why?
TIA

Lookup Table Named Range "TestLookUp"

Test Lookup
Key Value
1 Value1
2 Value2
3 Value3
4 Value4

private mChanging as boolean

Private Sub Worksheet_Change(ByVal Target As Range)

If mChanging then exit sub
If Target.Address < "$B$1" then exit sub

mChanging = true

Dim sNamedRange as string
sNamedRange =

replace(ActiveWorkbook.Names("TestLookUp").RefersT o,"=","")
If Not Application.IsError(Application.VLookup(Target.Val ue,
sNamedRange, 2, False)) Then
If Not
Application.WorksheetFunction.IsNA(Application.VLo okup(Target.Value,
sNamedRange, 2)) Then
Target.Worksheet.Range("$A$1").Formula = "VLOOKUP(""" &
target.address & """,""TestLookUp"",2)"
Else
Target.Worksheet.Range("$A$1").Formula = ""
Target.Worksheet.Range("$A$1").Value = ""
End If
End If

mChanging = false

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
excel.worksheetfunctions Max Excel Worksheet Functions 13 November 26th 05 02:25 AM
WorksheetFunctions PGalla06[_17_] Excel Programming 1 September 29th 05 11:29 PM
can I use WorksheetFunctions ON arrays from VBA?? fern Excel Programming 6 August 8th 05 09:27 PM
No VBA help for Worksheetfunctions available Toppers Excel Worksheet Functions 4 January 23rd 05 04:58 PM
Using WorksheetFunctions in Excel Macros Ken[_18_] Excel Programming 2 March 2nd 04 05:05 PM


All times are GMT +1. The time now is 02:08 AM.

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"