Logo 
Search:

MS Office Forum

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds

VLOOKUP in VBA

  Asked By: Ernesta    Date: Feb 04    Category: MS Office    Views: 1932
  

I have a form in which the user selects an account name from a
listbox. I'd like to have the account number automatically populate
in the account number textbox. Do I use VLOOKUP to do this? If so,
how?

Share: 

 

8 Answers Found

 
Answer #1    Answered By: Ulfah Hashmi     Answered On: Feb 04

I've posted an example file to the files page on the Group home page
which shows how to do this. I've shown how to write the value both to a
text box and to a label.

 
Answer #2    Answered By: Adaulfo Fischer     Answered On: Feb 04

I've tried your example file to another project. But
i'm still confused, why when i write rowsource at
properties windows still error.And why my procedure
about vlookup  still false.

 
Answer #3    Answered By: Lily Brown     Answered On: Feb 04

A few days, u bring to this group file example about
vlookup vba. And i try to another project refer to
vlookup vba  to. But in this case, i still trouble,
when i write range tabel at properties windows in VBA.
And my procedure vlookup  still error to.
Can u help me about this problem. Now, my attach file
(s1 Dist NTG.XLS) again.

 
Answer #4    Answered By: Umaiza Hashmi     Answered On: Feb 04

OK. I've now replied to your earlier post about your VBA vlookup  use not
working, so hopefully you've now got that fixed.

I think what you're saying is that you are trying to type in the name of
a range as the row source property for a control and it's not working,
although you don't say what's happening - are you getting an error
message, do you just get a blank list, or what? If there is a problem
with using the range name, check you have actually defined the name on
the worksheet and that you're spelling it correctly in the properties
table - and that there are no spaces or other punctuation in either
occurance of the name.

 
Answer #5    Answered By: Barachias Levi     Answered On: Feb 04

Error after i type in the name of a range in the
Property is " Could Not Set The RowSource Property.
Invalid Property value ".
Acctually defined the name on the worksheet and that
spelling it correctly in the properties
table - and that there are no spaces or other
punctuation in either occurance of the name.
I don't know, why still error?

 
Answer #6    Answered By: Naomi Lee     Answered On: Feb 04

I don't know either. As you've seen in my example, this works fine.

 
Answer #7    Answered By: Bathilda Schmidt     Answered On: Feb 04

I didn't see the original post but to use RowSource you just identify a string
that represents the address of the cells (see the help file, that's what it says
too). Attached is a .xls file with a simple form  with one combobox and one
listbox. Both have RowSource set to "TestData" which is a column of data on a
worksheet. If you're doing this in VBA instead of writing the name TestData
directly in the properties dialog then you need to include quotes around the
name.

The title of this thread is VLOOKUP but since the latest question is about
RowSource, I answered it based on that.

 
Answer #8    Answered By: Joyce Edwards     Answered On: Feb 04

To use the RowSource to set the data for a combob/listbox you need to
identify it as a string (see the help file, it's quite clear on this).

listbox1.rowsource = "myData"

where "myData" is some named range or an explicit address
like "Sheet4!A4:A10"

 
Didn't find what you were looking for? Find more on VLOOKUP in VBA Or get search suggestion and latest updates.




Tagged: