GTretick
Member
I've created a small database of several countries with many corresponding cities which can be found on the worksheet Lists. Some countries have one city in the list and some have several.
I have a named range in Excel called CityList.
I want to dynamically change the range of this named range so that it starts at the first city that corresponds to the selected country and ends with the last city for the same selected country.
I've created some VBA code that effectively identifies the starting and ending row required.
I've also created code that redefined the list range.
The problem is the list range is hard coded not dynamic to react to any variables.
I'd like some help defining the syntax needed to make the hard coding variable.
What should happen is in the worksheet 'Main', you can select a country from the dropdown in A6 to A10. The corresponding cell in B has a dropdown referring to the range CityList. This should give you only the cities from that country.
I've got some data in column H that I was using to ensure my variables were being filled with the correct data which they seem to be. That part will be deleted when final coding is correct.
Sidenote: You may notice the dropdown in column A has duplicates for countries with more than one named city. My secondary problem will be to reduce that to unique values. If you want a crack at that problem I'm open to suggestions there too. If the answer is more VBA based than helper column based that would be ideal but any suggestion is good.
I have a named range in Excel called CityList.
I want to dynamically change the range of this named range so that it starts at the first city that corresponds to the selected country and ends with the last city for the same selected country.
I've created some VBA code that effectively identifies the starting and ending row required.
I've also created code that redefined the list range.
The problem is the list range is hard coded not dynamic to react to any variables.
I'd like some help defining the syntax needed to make the hard coding variable.
What should happen is in the worksheet 'Main', you can select a country from the dropdown in A6 to A10. The corresponding cell in B has a dropdown referring to the range CityList. This should give you only the cities from that country.
I've got some data in column H that I was using to ensure my variables were being filled with the correct data which they seem to be. That part will be deleted when final coding is correct.
Sidenote: You may notice the dropdown in column A has duplicates for countries with more than one named city. My secondary problem will be to reduce that to unique values. If you want a crack at that problem I'm open to suggestions there too. If the answer is more VBA based than helper column based that would be ideal but any suggestion is good.