+ Reply to Thread
Results 1 to 10 of 10

How to lookup a different number of cities?

  1. #1
    Forum Contributor
    Join Date
    06-30-2018
    Location
    Sweden
    MS-Off Ver
    2016.
    Posts
    397

    How to lookup a different number of cities?

    I have an activex combobox and 3 lists of cities in countries, when I select a country in the dropdown I want to lookup all cities in that country.

    The number of cities varies between the countries.

    E.g. Sweden might have 25 cities and Norway might have 12 cities.

    See attached file.

  2. #2
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,908

    Re: How to lookup a different number of cities?

    One way to do it.

    Please Login or Register  to view this content.
    Avoid using Select, Selection and Activate in your code. Use With ... End With instead.
    You can show your appreciation for those that have helped you by clicking the * at the bottom left of any of their posts.

  3. #3
    Forum Contributor
    Join Date
    06-30-2018
    Location
    Sweden
    MS-Off Ver
    2016.
    Posts
    397

    Re: How to lookup a different number of cities?

    Hi bakerman2,

    thank you for your reply!

    Your code works great and I get that I can change cell H6 and also expand it to more countries.


    I have another question. If I have two comboboxes that are dependent on each other, like country and city.

    How can I use SUMIFS and COUNTIFS on the first combobox1 and perform one lookup and then if I click the other combobox2 I want to perform a different lookup?

    Ex. First I select Sweden and then I want to use one SUMIFS/COUNTIFS/VLOOKUP and then I want more granularity and I select Stockholm I want to use other SUMIFS/COUNTIFS/VLOOKUP?


    Nested IF statements perhaps?

  4. #4
    Forum Contributor
    Join Date
    06-30-2018
    Location
    Sweden
    MS-Off Ver
    2016.
    Posts
    397

    Re: How to lookup a different number of cities?

    bakerman2,

    would it be possible to resize sn to two or three columns?

    Say there are 20 cities, then it would be in column (H6).

    Say there are 40 cities, then it would be in (H6 and I6)

    Say there are 60 cities, then it would be in (H6, I6 and J6)??

  5. #5
    Forum Contributor
    Join Date
    06-30-2018
    Location
    Sweden
    MS-Off Ver
    2016.
    Posts
    397

    Re: How to lookup a different number of cities?

    I think that I should access items 0-20, 21-40 and 41-60 using if statements or select case statements?

    sn is an array?

  6. #6
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,081

    Re: How to lookup a different number of cities?

    To split the output, how about
    Please Login or Register  to view this content.

  7. #7
    Forum Contributor
    Join Date
    06-30-2018
    Location
    Sweden
    MS-Off Ver
    2016.
    Posts
    397

    Re: How to lookup a different number of cities?

    Hi Fluff13,

    thank you for your reply!

    Your code is working really well. Thank you!

  8. #8
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,081

    Re: How to lookup a different number of cities?

    Glad to help & thanks for the feedback

  9. #9
    Forum Contributor
    Join Date
    06-30-2018
    Location
    Sweden
    MS-Off Ver
    2016.
    Posts
    397

    Re: How to lookup a different number of cities?

    I have an additional question, would it be possible to create hyperlinks in the same code?

    So that each item becomes a hyperlink that links to it name??

    Please Login or Register  to view this content.
    Say Row1 and Row2 are Stockholm and Oslo.

    Then when I change ComboBox1,

    I get the named ranges with hyperlinks to sheets "Stockholm" and "Oslo"?

  10. #10
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,908

    Re: How to lookup a different number of cities?


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Pie chart - Cities & Amounts
    By Histeven in forum Excel Charting & Pivots
    Replies: 3
    Last Post: 04-15-2019, 07:56 AM
  2. [SOLVED] fix the cities in addresses
    By KingTamo in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 03-03-2018, 02:47 PM
  3. How to get the counts for different cities in a certain period.
    By rvfotopro in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 05-14-2017, 03:55 PM
  4. counting cities
    By TheVolkinator in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 12-26-2014, 02:35 PM
  5. How to generate all possible combinations of nine cities
    By Nikolas1988 in forum Excel General
    Replies: 2
    Last Post: 06-09-2014, 09:21 AM
  6. Macro to filter cities
    By rafuk73 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 10-31-2013, 09:56 AM
  7. Many Cities into few Regions
    By Johnny Image in forum Excel General
    Replies: 2
    Last Post: 04-17-2012, 07:25 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1