PC Review


Reply
Thread Tools Rate Thread

Combo Box: Vlookup Multiple Cells by referencing to Text Box

 
 
BigMac
Guest
Posts: n/a
 
      18th Oct 2006
Hi there. I'm currently doing a volunteer project on setting up a
borrowing system for a small museum library using EXCEL and VBA,
however my knowledge of VBA is truly rudimentary, so I need a lot of
help from the experts here.

The main problem I face now is this: The library makes use of the Dewey
Decimal Number (DDN) system to keep track of its books. However this
DDN is not unique to each book i.e. one DDN can have many books.

As I did up my user form, everything was successful up till the point
whereby I set up a combobox which references to a book database. By
typing the DDN into a textbox, all the books having the same DDN should
appear in the combobox. My simple programming is as below:


Private Sub cmdFindBook_Click()

Dim MyRange As Variant
Dim MyRange2 As Variant
Dim colNumber As Long

MyRange = Sheets("Book Database").Range("B5:G1878").Value
MyRange2 = Sheets("Book Database").Range("C51878").Value

cbxBookTitle.Text = ""
lblAuthor.Caption = ""

On Error GoTo Errorhandler

If txtDDN.Text = "" Then

MsgBox ("Please enter Dewey Decimal Number.")

Else

cbxBookTitle.Text = Application.WorksheetFunction.VLookup(txtDDN.Text,
MyRange, 2, False)
lblAuthor.Caption =
Application.WorksheetFunction.VLookup(cbxBookTitle.Text, MyRange2, 2,
False)

End If
Exit Sub

Errorhandler:
MsgBox ("No book found.")


End Sub

Foolish me is unable to get a list of the books with the same DDN to
appear in the combo box drop down list. Can anyone give me any guidance
at all? I understand it might be something pretty complex, so thank you
guys for your help

Cheers!
Mac

 
Reply With Quote
 
 
 
 
dolivastro@gmail.com
Guest
Posts: n/a
 
      18th Oct 2006
Well, you might take this as nothing but a teaser, but I think you are
using the wrong application. The books of a library, even a small one,
belong in a database. My advice is: Move over to Access, or (what I
think is better) to a stand alone VB executable that uses ADO to
connect to the Access backend.

What you are doing is called "querying a database", and you want to
populate the combo box with the ResultSet.

I know that doesn't help, in fact it makes things more difficult for
you, but I think you are going to write a large Excel / VBA program
that crashes once you get too many books in your database. So ...
change now!

Just my $.02

Dom



BigMac wrote:
> Hi there. I'm currently doing a volunteer project on setting up a
> borrowing system for a small museum library using EXCEL and VBA,
> however my knowledge of VBA is truly rudimentary, so I need a lot of
> help from the experts here.
>
> The main problem I face now is this: The library makes use of the Dewey
> Decimal Number (DDN) system to keep track of its books. However this
> DDN is not unique to each book i.e. one DDN can have many books.
>
> As I did up my user form, everything was successful up till the point
> whereby I set up a combobox which references to a book database. By
> typing the DDN into a textbox, all the books having the same DDN should
> appear in the combobox. My simple programming is as below:
>
>
> Private Sub cmdFindBook_Click()
>
> Dim MyRange As Variant
> Dim MyRange2 As Variant
> Dim colNumber As Long
>
> MyRange = Sheets("Book Database").Range("B5:G1878").Value
> MyRange2 = Sheets("Book Database").Range("C51878").Value
>
> cbxBookTitle.Text = ""
> lblAuthor.Caption = ""
>
> On Error GoTo Errorhandler
>
> If txtDDN.Text = "" Then
>
> MsgBox ("Please enter Dewey Decimal Number.")
>
> Else
>
> cbxBookTitle.Text = Application.WorksheetFunction.VLookup(txtDDN.Text,
> MyRange, 2, False)
> lblAuthor.Caption =
> Application.WorksheetFunction.VLookup(cbxBookTitle.Text, MyRange2, 2,
> False)
>
> End If
> Exit Sub
>
> Errorhandler:
> MsgBox ("No book found.")
>
>
> End Sub
>
> Foolish me is unable to get a list of the books with the same DDN to
> appear in the combo box drop down list. Can anyone give me any guidance
> at all? I understand it might be something pretty complex, so thank you
> guys for your help
>
> Cheers!
> Mac


 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Referencing Multiple Worksheets using VLOOKUP and INDIRECT Harry Flashman Microsoft Excel Discussion 0 24th Jun 2009 08:27 AM
Using vlookup when referencing text =?Utf-8?B?cGJsZW5pcw==?= Microsoft Excel Misc 3 26th Jun 2006 10:12 PM
Vlookup? Referencing cells? =?Utf-8?B?S2FyZW4=?= Microsoft Excel Worksheet Functions 4 26th Jun 2006 04:42 PM
Referencing cells using a combo box Chip Pulitzer Microsoft Excel Misc 1 29th May 2004 05:02 PM
vlookup + combo boxes, referencing... plz help :'( kieranbeunco Microsoft Excel Misc 1 14th Mar 2004 10:07 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:52 PM.