Excel/VBA

Advertisement


Question
Dear Gulshan,

Please help me, the below code helps me to retrieve the information from a small database based on textbox2, Can you help me to add another criteria on combobox2 which will give me a list by lookup from column C then populate the information on userform

for eg:

case101 has 2 files namely A & B

when i do the search on case101 the dropdown gives me the option to choose AorB and when I select A it populates the information on the userform.

I have got this far but not able to populate through dropdown..

I highly appreciate your kind help in advance

Aji

Private Sub CommandButton1_Click()
row_number = 0
Do
DoEvents
row_number = row_number + 1
item_in_review = Sheets("Sheet1").Range("B" & row_number)
If item_in_review = TextBox2.Text Then
TextBox1.Text = Sheets("Sheet1").Range("D" & row_number)
TextBox4.Text = Sheets("Sheet1").Range("E" & row_number)
ComboBox1.Text = Sheets("Sheet1").Range("F" & row_number)
TextBox3.Text = Sheets("Sheet1").Range("G" & row_number)


Loop Until item_in_review = ""

End Sub

Answer
Hi Aji,

I'm not sure why you are trying to populate the value in a combo box:
ComboBox1.Text = Sheets("Sheet1").Range("F" & row_number)
Since you are always going to populate it through the macro, why not just create this as a normal text box and populate it?

Since I don't have the exact error you are facing, my first guess is that you are getting the error that value cannot be populated in combobox because you have not defined the list of values for that combobox. If the values are not a part of the list, you won't be able to populate them.

To define the list of options, right click on the combo box in design mode, select properties and define the range in "Listfillrange"

Hope this helps,

Thanks,
Gulshan.
About Excel
This topic answers questions related to Microsoft Excel spreadsheet (or workbook) stand-alone or Mircrosoft Office Excel including Excel 2003, Excel 2007, Office 2000, and Office XP. You can get Excel help on Excel formulas(or functions), Excell macros, charting in Excel, advanced features, and the general use of Excel. This does not provide a general Excel tutorial nor the basics of using a spreadsheet. It provides specific answers to using Microsoft Excel only. If you do not see your Excel question answered in this area then please ask an Excel question here

Excel

All Answers


Answers by Expert:


Ask Experts

Volunteer


GULSHAN PURSWANI

Expertise

I can answer questions related to the following topics: 1. MS Excel - Creating and Linking Formulae, Running Pivot Tables, Vlookup etc. 2. Macros / VBA - Creating Macros to do specific jobs. Importing / Exporting / Validating Data in excel through Macros.

Experience

I've been working on excel for over 10 years and on VBA macros for over 3 years now.

Education/Credentials
Bachelor of Commerce, Chartered Accountant from The Institute of Chartered Accountants of India

©2016 About.com. All rights reserved.