Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 80
Default Vlookup funtion in Userform

Hi All,
i really wonder why I cannot refer the textbox value in the userform
while using vlookup function in VBA.
For example:
' TextBox6 = Application.VLookup(Userform1.TextBox1.value,
Sheet4.Range("staff"), 3, False)
Any idea why above code does not work?

Thanks a lot
Baha
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,420
Default Vlookup funtion in Userform

It should work.

is the code called from the form?

and in what way does it not work?

--
__________________________________
HTH

Bob

wrote in message
...
Hi All,
i really wonder why I cannot refer the textbox value in the userform
while using vlookup function in VBA.
For example:
' TextBox6 = Application.VLookup(Userform1.TextBox1.value,
Sheet4.Range("staff"), 3, False)
Any idea why above code does not work?

Thanks a lot
Baha



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 80
Default Vlookup funtion in Userform

On Aug 7, 3:40*pm, " wrote:
Hi All,
i really wonder why I cannot refer the textbox value in the userform
while using vlookup function in VBA.
For example:
' TextBox6 = Application.VLookup(Userform1.TextBox1.value,
Sheet4.Range("staff"), 3, False)
Any idea why above code does not work?

Thanks a lot
Baha




Hi,
Yes it is called from the userform by clicking command button in the
userform1 ad it gives run time error like"could not set the value
property.Type mismatch"
Thanks for the help
Baha
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Vlookup funtion in Userform

I'd try something like:

Dim res as variant
....
res = Application.VLookup(me.TextBox1.value, Sheet4.Range("staff"), 3, False)
if iserror(res) then
me.textbox6.value = "No Match!"
else
me.textbox6.value = res
end if

And if the values in the first column of that Staff range are numbers, you'll
want to convert me.textbox1.value to a number

if isnumeric(me.textbox1.value) then
res = Application.VLookup(clng(me.TextBox1.value), _
Sheet4.Range("staff"), 3, False)
else
res = "Invalid entry in textbox1"
end if






" wrote:

Hi All,
i really wonder why I cannot refer the textbox value in the userform
while using vlookup function in VBA.
For example:
' TextBox6 = Application.VLookup(Userform1.TextBox1.value,
Sheet4.Range("staff"), 3, False)
Any idea why above code does not work?

Thanks a lot
Baha


--

Dave Peterson
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 80
Default Vlookup funtion in Userform

On Aug 7, 7:46*pm, Dave Peterson wrote:
I'd try something like:

Dim res as variant
...
res = Application.VLookup(me.TextBox1.value, Sheet4.Range("staff"), 3, False)
if iserror(res) then
* me.textbox6.value = "No Match!"
else
* me.textbox6.value = res
end if

And if the values in the first column of that Staff range are numbers, you'll
want to convert me.textbox1.value to a number

if isnumeric(me.textbox1.value) then
* *res = Application.VLookup(clng(me.TextBox1.value), _
* * * * * * * * * * * * * * *Sheet4.Range("staff"), 3, False)
else
* *res = "Invalid entry in textbox1"
end if

" wrote:

Hi All,
i really wonder why I cannot refer the textbox value in the userform
while using vlookup function in VBA.
For example:
' TextBox6 = Application.VLookup(Userform1.TextBox1.value,
Sheet4.Range("staff"), 3, False)
Any idea why above code does not work?


Thanks a lot
Baha


--

Dave Peterson


Thanks a lot Dave it works fine. I did not know that "CLng" thing:)
have a good day to all
Baha
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 funtion is not working properly? Kathyrn Excel Worksheet Functions 1 September 29th 08 04:49 PM
Vlookup in Userform - XL2003 Steve Jones Excel Programming 4 July 26th 07 03:00 PM
VLOOKUP, correct funtion? dee student Excel Worksheet Functions 3 June 4th 06 10:14 AM
Vlookup (and/or) IF funtion Serge Excel Discussion (Misc queries) 1 February 20th 06 05:38 AM
Vlookup in a userform R D S Excel Discussion (Misc queries) 6 January 26th 05 09:22 PM


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