Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Combo Box: Vlookup Multiple Cells by referencing to Text Box

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("C5:D1878").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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 46
Default Combo Box: Vlookup Multiple Cells by referencing to Text Box

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("C5:D1878").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
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
Referencing Cells in Multiple Worksheets RS Excel Worksheet Functions 2 March 8th 10 05:46 PM
Referencing cells in multiple worksheets Andrew W Excel Discussion (Misc queries) 3 August 6th 08 02:23 PM
Directly referencing multiple cells Link New Users to Excel 4 April 11th 07 05:40 PM
Using vlookup when referencing text pblenis Excel Discussion (Misc queries) 3 June 26th 06 10:12 PM
Vlookup? Referencing cells? Karen Excel Worksheet Functions 4 June 26th 06 04:42 PM


All times are GMT +1. The time now is 02:43 AM.

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"