Hi All,
I have the below code which works fine with Combo box. Now when try to replicate it for listbox it doesn't work properly.
Background : I have sql table called "Region_Mapping" with two columns one is country and another is region and as far as data in both columns is concerned is basically Region and country. For e.g. In country column i have country names like USA, Brazil, Mexico and Argentina and against same country names I have region as America in Region column.
What I want : I want to sql table data in my excel userform combobox and listbox .i.e In combo box I want to populate region names (which is already done and works fine) and in list box I want to populate country names on the basis of region selection. for e.g. If I select region as America in my Combo box then my listbox should get populated with only countries of America region .i.e USA, Brazil, Mexico and Argentina.
Code which I have so Far :
I have pasted the below code in Module 1 :
I have pasted the below code in userform background :
Issue : Now the issue is I have observed that it's not populating countries of those regions which have multiple countries mapped under it / mentioned against it in sql table for e.g. America has Mexico, Brazil, Argentina and USA mentioned against it in sql table but it populates the country name only for regions like Germany, UK & Japan as this regions have only one country mentioned against them in sql table.
Now this code should work for those regions which have multiple countries mapped against them in sql table.
Please help.
Thanks for your help in advance.
Bookmarks