Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Help with vlookup

Below is my code. I keep receiving a "Type Mismatch" error '13'. And no
matter what I try I can't get it to work. Please help!


Sub GetAnswer()
' Created by CJ
'Enter an abbreviation and this will tell you which branch it is for.
Dim Num As Variant
Dim Answer As Variant
Dim msg As String
Dim Ans As Variant
Dim Nums As Variant

'Prompt for a value
Do
Num = InputBox("What is the branch number you would like to look up?")

'Exit if cancelled
If Num = "" Then Exit Sub

'Look up the abbreviation and return an answer.
Answer = Application.VLookup(Num, "Branch Numbers", 4, False)


MsgBox Answer

'Show which branch the number goes to
MsgBox Num & " is the PDSN Branch #" & Answer & "."

'Ask if they would like to look up another number
msg = MsgBox("Would you like to look up another branch?", vbYesNo)
Loop While msg = vbYes

End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 857
Default Help with vlookup

Hi,

I assume "Branch Numbers" is a named range? try it this way:

Answer = Application.VLookup(Num, Range("Branch Numbers"), 4, False)


--
Hope that helps.

Vergel Adriano


"csjames" wrote:

Below is my code. I keep receiving a "Type Mismatch" error '13'. And no
matter what I try I can't get it to work. Please help!


Sub GetAnswer()
' Created by CJ
'Enter an abbreviation and this will tell you which branch it is for.
Dim Num As Variant
Dim Answer As Variant
Dim msg As String
Dim Ans As Variant
Dim Nums As Variant

'Prompt for a value
Do
Num = InputBox("What is the branch number you would like to look up?")

'Exit if cancelled
If Num = "" Then Exit Sub

'Look up the abbreviation and return an answer.
Answer = Application.VLookup(Num, "Branch Numbers", 4, False)


MsgBox Answer

'Show which branch the number goes to
MsgBox Num & " is the PDSN Branch #" & Answer & "."

'Ask if they would like to look up another number
msg = MsgBox("Would you like to look up another branch?", vbYesNo)
Loop While msg = vbYes

End Sub

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Help with vlookup

That works. When I'm testing my vlookup using a message box I get the same
run-time error '13': Type mismatch.

See "MsgBox Answer" in code below

tnx

"Vergel Adriano" wrote:

Hi,

I assume "Branch Numbers" is a named range? try it this way:

Answer = Application.VLookup(Num, Range("Branch Numbers"), 4, False)


--
Hope that helps.

Vergel Adriano


"csjames" wrote:

Below is my code. I keep receiving a "Type Mismatch" error '13'. And no
matter what I try I can't get it to work. Please help!


Sub GetAnswer()
' Created by CJ
'Enter an abbreviation and this will tell you which branch it is for.
Dim Num As Variant
Dim Answer As Variant
Dim msg As String
Dim Ans As Variant
Dim Nums As Variant

'Prompt for a value
Do
Num = InputBox("What is the branch number you would like to look up?")

'Exit if cancelled
If Num = "" Then Exit Sub

'Look up the abbreviation and return an answer.
Answer = Application.VLookup(Num, "Branch Numbers", 4, False)


MsgBox Answer

'Show which branch the number goes to
MsgBox Num & " is the PDSN Branch #" & Answer & "."

'Ask if they would like to look up another number
msg = MsgBox("Would you like to look up another branch?", vbYesNo)
Loop While msg = vbYes

End Sub

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Help with vlookup

if iserror(answer) then
msgbox "no match"
else
msgbox Answer
end if

Are your branch numbers strings are numbers?

maybe:
Answer = Application.VLookup(clng(Num), Range("Branch Numbers"), 4, False)

to convert the string that's returned with the Inputbox to a number.


csjames wrote:

That works. When I'm testing my vlookup using a message box I get the same
run-time error '13': Type mismatch.

See "MsgBox Answer" in code below

tnx

"Vergel Adriano" wrote:

Hi,

I assume "Branch Numbers" is a named range? try it this way:

Answer = Application.VLookup(Num, Range("Branch Numbers"), 4, False)


--
Hope that helps.

Vergel Adriano


"csjames" wrote:

Below is my code. I keep receiving a "Type Mismatch" error '13'. And no
matter what I try I can't get it to work. Please help!


Sub GetAnswer()
' Created by CJ
'Enter an abbreviation and this will tell you which branch it is for.
Dim Num As Variant
Dim Answer As Variant
Dim msg As String
Dim Ans As Variant
Dim Nums As Variant

'Prompt for a value
Do
Num = InputBox("What is the branch number you would like to look up?")

'Exit if cancelled
If Num = "" Then Exit Sub

'Look up the abbreviation and return an answer.
Answer = Application.VLookup(Num, "Branch Numbers", 4, False)


MsgBox Answer

'Show which branch the number goes to
MsgBox Num & " is the PDSN Branch #" & Answer & "."

'Ask if they would like to look up another number
msg = MsgBox("Would you like to look up another branch?", vbYesNo)
Loop While msg = vbYes

End Sub


--

Dave Peterson
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Help with vlookup

The problem is that there are matches and the code is acting like they don't
exist. I'm using a number to vlookup from a list of numbers. What format
does the input box use when taking the information to vlookup?

"Dave Peterson" wrote:

if iserror(answer) then
msgbox "no match"
else
msgbox Answer
end if

Are your branch numbers strings are numbers?

maybe:
Answer = Application.VLookup(clng(Num), Range("Branch Numbers"), 4, False)

to convert the string that's returned with the Inputbox to a number.


csjames wrote:

That works. When I'm testing my vlookup using a message box I get the same
run-time error '13': Type mismatch.

See "MsgBox Answer" in code below

tnx

"Vergel Adriano" wrote:

Hi,

I assume "Branch Numbers" is a named range? try it this way:

Answer = Application.VLookup(Num, Range("Branch Numbers"), 4, False)


--
Hope that helps.

Vergel Adriano


"csjames" wrote:

Below is my code. I keep receiving a "Type Mismatch" error '13'. And no
matter what I try I can't get it to work. Please help!


Sub GetAnswer()
' Created by CJ
'Enter an abbreviation and this will tell you which branch it is for.
Dim Num As Variant
Dim Answer As Variant
Dim msg As String
Dim Ans As Variant
Dim Nums As Variant

'Prompt for a value
Do
Num = InputBox("What is the branch number you would like to look up?")

'Exit if cancelled
If Num = "" Then Exit Sub

'Look up the abbreviation and return an answer.
Answer = Application.VLookup(Num, "Branch Numbers", 4, False)


MsgBox Answer

'Show which branch the number goes to
MsgBox Num & " is the PDSN Branch #" & Answer & "."

'Ask if they would like to look up another number
msg = MsgBox("Would you like to look up another branch?", vbYesNo)
Loop While msg = vbYes

End Sub


--

Dave Peterson



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Help with vlookup

Thank you so much DAVE!!! I used the clng() and it worked perfectly. Again,
thanks so much!!!

"csjames" wrote:

The problem is that there are matches and the code is acting like they don't
exist. I'm using a number to vlookup from a list of numbers. What format
does the input box use when taking the information to vlookup?

"Dave Peterson" wrote:

if iserror(answer) then
msgbox "no match"
else
msgbox Answer
end if

Are your branch numbers strings are numbers?

maybe:
Answer = Application.VLookup(clng(Num), Range("Branch Numbers"), 4, False)

to convert the string that's returned with the Inputbox to a number.


csjames wrote:

That works. When I'm testing my vlookup using a message box I get the same
run-time error '13': Type mismatch.

See "MsgBox Answer" in code below

tnx

"Vergel Adriano" wrote:

Hi,

I assume "Branch Numbers" is a named range? try it this way:

Answer = Application.VLookup(Num, Range("Branch Numbers"), 4, False)


--
Hope that helps.

Vergel Adriano


"csjames" wrote:

Below is my code. I keep receiving a "Type Mismatch" error '13'. And no
matter what I try I can't get it to work. Please help!


Sub GetAnswer()
' Created by CJ
'Enter an abbreviation and this will tell you which branch it is for.
Dim Num As Variant
Dim Answer As Variant
Dim msg As String
Dim Ans As Variant
Dim Nums As Variant

'Prompt for a value
Do
Num = InputBox("What is the branch number you would like to look up?")

'Exit if cancelled
If Num = "" Then Exit Sub

'Look up the abbreviation and return an answer.
Answer = Application.VLookup(Num, "Branch Numbers", 4, False)


MsgBox Answer

'Show which branch the number goes to
MsgBox Num & " is the PDSN Branch #" & Answer & "."

'Ask if they would like to look up another number
msg = MsgBox("Would you like to look up another branch?", vbYesNo)
Loop While msg = vbYes

End Sub


--

Dave Peterson

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Help with vlookup

Sometimes, I bury the lead!

csjames wrote:

Thank you so much DAVE!!! I used the clng() and it worked perfectly. Again,
thanks so much!!!

"csjames" wrote:

The problem is that there are matches and the code is acting like they don't
exist. I'm using a number to vlookup from a list of numbers. What format
does the input box use when taking the information to vlookup?

"Dave Peterson" wrote:

if iserror(answer) then
msgbox "no match"
else
msgbox Answer
end if

Are your branch numbers strings are numbers?

maybe:
Answer = Application.VLookup(clng(Num), Range("Branch Numbers"), 4, False)

to convert the string that's returned with the Inputbox to a number.


csjames wrote:

That works. When I'm testing my vlookup using a message box I get the same
run-time error '13': Type mismatch.

See "MsgBox Answer" in code below

tnx

"Vergel Adriano" wrote:

Hi,

I assume "Branch Numbers" is a named range? try it this way:

Answer = Application.VLookup(Num, Range("Branch Numbers"), 4, False)


--
Hope that helps.

Vergel Adriano


"csjames" wrote:

Below is my code. I keep receiving a "Type Mismatch" error '13'. And no
matter what I try I can't get it to work. Please help!


Sub GetAnswer()
' Created by CJ
'Enter an abbreviation and this will tell you which branch it is for.
Dim Num As Variant
Dim Answer As Variant
Dim msg As String
Dim Ans As Variant
Dim Nums As Variant

'Prompt for a value
Do
Num = InputBox("What is the branch number you would like to look up?")

'Exit if cancelled
If Num = "" Then Exit Sub

'Look up the abbreviation and return an answer.
Answer = Application.VLookup(Num, "Branch Numbers", 4, False)


MsgBox Answer

'Show which branch the number goes to
MsgBox Num & " is the PDSN Branch #" & Answer & "."

'Ask if they would like to look up another number
msg = MsgBox("Would you like to look up another branch?", vbYesNo)
Loop While msg = vbYes

End Sub

--

Dave Peterson


--

Dave Peterson
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
Vlookup in vlookup - taking the result as array name SupperDuck Excel Worksheet Functions 2 June 2nd 07 11:05 AM
Combine VLOOKUP and IF function so #NA isn't returned as a value from VLOOKUP buffgirl71 Excel Discussion (Misc queries) 12 November 14th 06 11:36 PM
Which is faster: VLOOKUP-worksheet or VB-array VLOOKUP? erikhs[_20_] Excel Programming 1 August 6th 06 06:18 PM
Vlookup -=VLOOKUP(F9,LookUp1!$A$2:$B$1504,2,FALSE) MikeR-Oz New Users to Excel 1 March 22nd 06 09:01 AM
Vlookup info being used without vlookup table attached? Excel Worksheet Functions 0 January 25th 05 10:43 AM


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