Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 162
Default Excel VB User Form Using Vlookup?

Hello Fellow Programmers! I am having a difficult time trying to get my
user form to search through a spreadsheet and retrieve the information
using the Application.Vlookup code...I have searched numerous other
posts and haven't found one code that worked the way I needed it to.

Private Sub TextBox10_Change()
x = Application.VLookup(TextBox10.Value,
Worksheets("SYSDATA").Range("A2:J30"), 2, False)
TextBox1.Value = x

End Sub

The objective is I have a Record Number listed in TextBox10... I have
information setup in the spreadsheet that I would liked filled in
TextBoxes 1 - 9 based on the value of TextBox10. I have tried to use
the code above to work but it keeps giving me a error message saying
"Could not set the Value property. Type Mismatch"...So my question is
how can I have my 9 other text boxes use the Vlookup code (using the
value from Textbox10 as the search value, to retrieve the information
based on its value?) TextBox10 will always be a number (for now)...I
might need the code to lookup the value of a non-numerical string at
some point but I'll be happy with just having the vlookup code work.
Any help is greatly appreciated!!!

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Excel VB User Form Using Vlookup?

If the VLookup doesn't find a match, it return a Variant containing an error
type variable. Your code will fail on
TextBox1.Value = x
if x contains an error value. You can test x with IsError. E.g.,

If IsError(X) = True Then
MsgBox "Data Not Found"
Else
TextBox1.Value = X
End If


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
(email address is on the web site)


wrote in message
ups.com...
Hello Fellow Programmers! I am having a difficult time trying to get my
user form to search through a spreadsheet and retrieve the information
using the Application.Vlookup code...I have searched numerous other
posts and haven't found one code that worked the way I needed it to.

Private Sub TextBox10_Change()
x = Application.VLookup(TextBox10.Value,
Worksheets("SYSDATA").Range("A2:J30"), 2, False)
TextBox1.Value = x

End Sub

The objective is I have a Record Number listed in TextBox10... I have
information setup in the spreadsheet that I would liked filled in
TextBoxes 1 - 9 based on the value of TextBox10. I have tried to use
the code above to work but it keeps giving me a error message saying
"Could not set the Value property. Type Mismatch"...So my question is
how can I have my 9 other text boxes use the Vlookup code (using the
value from Textbox10 as the search value, to retrieve the information
based on its value?) TextBox10 will always be a number (for now)...I
might need the code to lookup the value of a non-numerical string at
some point but I'll be happy with just having the vlookup code work.
Any help is greatly appreciated!!!



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 162
Default Excel VB User Form Using Vlookup?

Chip,

I appreciate you taking the time to inform me of this...however, your
new addition to my code is displaying a new error message...

"Could not set the Value property. Type mismatch."

If you think you know how to do this then please provide me the code...
the variable of the code are below...

Lookup Value From UserForm1 = Textbox10
-- Textbox10 is a number derived from the record number
Area in spreadsheet where data is = SYSDATA!A2:J30
Column of where the data is = 2

I don't care what the function is called I just want it so when a
end-user changes the value of textbox 10 it will update every other
textbox in the user form. Your help as well as anyone elses is much
appreciated!!!

Thanks alot!

-Todd



Chip Pearson wrote:
If the VLookup doesn't find a match, it return a Variant containing an error
type variable. Your code will fail on
TextBox1.Value = x
if x contains an error value. You can test x with IsError. E.g.,

If IsError(X) = True Then
MsgBox "Data Not Found"
Else
TextBox1.Value = X
End If


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
(email address is on the web site)


wrote in message
ups.com...
Hello Fellow Programmers! I am having a difficult time trying to get my
user form to search through a spreadsheet and retrieve the information
using the Application.Vlookup code...I have searched numerous other
posts and haven't found one code that worked the way I needed it to.

Private Sub TextBox10_Change()
x = Application.VLookup(TextBox10.Value,
Worksheets("SYSDATA").Range("A2:J30"), 2, False)
TextBox1.Value = x

End Sub

The objective is I have a Record Number listed in TextBox10... I have
information setup in the spreadsheet that I would liked filled in
TextBoxes 1 - 9 based on the value of TextBox10. I have tried to use
the code above to work but it keeps giving me a error message saying
"Could not set the Value property. Type Mismatch"...So my question is
how can I have my 9 other text boxes use the Vlookup code (using the
value from Textbox10 as the search value, to retrieve the information
based on its value?) TextBox10 will always be a number (for now)...I
might need the code to lookup the value of a non-numerical string at
some point but I'll be happy with just having the vlookup code work.
Any help is greatly appreciated!!!


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 User Form MG Excel Worksheet Functions 0 February 25th 09 12:58 AM
Minimize excel user form Hammer1947 Excel Programming 5 July 15th 06 06:29 AM
How to: User Form to assign a user defined range to a macro variab TrevTrav Excel Programming 1 March 22nd 05 07:57 PM
How do I create a user form in excel? Carey Excel Programming 3 August 13th 04 01:26 PM


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