VBA: Dependent Comboboxes and Dynamic Ranges

GarC

New Member
Joined
Nov 9, 2011
Messages
15
Hi
This is my first post on this forum and I know that you will be able to help me as from my searches I can see that this has been asked and answered
before (but I couldn't quite understand the answers). I am actually very close to fixing this myself but being someone who has only discovered VBA
in the last few weeks I am finding the learning curve pretty steep.


Anyway, using a tutorial I found on fontstuff.com, I am creating a user form which I want my team members to complete.
The data entered should feed into an excel sheet for analysis.

As you can see from the first screen shot I have created a fairly large user form and have now begun to work my way down through the code.
Most fields will be simple numerical or text fields but there are some Comboboxes I want to control.

mail


My first problem is trying to get one combo box to be dependent on another.
I have practiced with a simple version using Andrew Poulsom’s advice in this thread and got it to work fine.
I have also read the other threads linked in that thread.


However when I try to copy the VB code into my form, something is not quite right.

The problem details are as follows:
I want to select the Portfolio Manager from the first Combobox. This Combobox is named cboPortfolioManager
The list of portfolio managers is on a dynamic range named Portfolio_Manager. (See excel screen below – column A)
This part works fine.

mail


The issue is when I try to select the Company Name from the second Combobox, it remains blank. I am not getting any error messages.
Just nothing appearing in the drop down menu.

mail


This second Combobox is named cboCompanyName. The company names are also on dynamic ranges, named after their relationship manager.
Each of these ranges has exactly the same name as selected from the first Combobox so for the screen shot above, the portfolio manager is
AH_POL and I therefore want the company name Combobox to list the companies managed by AH_POL. (see excel screen below – Column C)


Below is a screen shot showing the layout of my dynamic ranges.
There are c.30 columns with each containing between 5 and 20 companies.
As you will understand I have whitened out the font for two columns and
Amended the actual company names in the dynamic range AH_POL

mail


Some basics
I am using Windows XP Pro and Excel 2003

Below is the code I have in my VB window
You can see from the ‘comments that I have been trying to eliminate the issue one line at a time but am now turning to you guys.

Private Sub UserForm_Activate()
cboPortfolioManager.RowSource = "Portfolio_Manager"
End Sub

Private Sub cboCompanyName_Change()
cboCompanyName.RowSource = cboPortfolioManager.Value
End Sub

Private Sub cboPortfolioManager_Change()
'cboPortfolioManager.RowSource = "Portfolio_Manager"
'cboCompanyName.RowSource = cboPortfolioManager.Value
End Sub

If you managed to read all the way down to here, THANK YOU.
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.

Forum statistics

Threads
1,203,668
Messages
6,056,653
Members
444,880
Latest member
Kinger1968

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top