+ Reply to Thread
Results 1 to 3 of 3

Using arrays to create Combobox items

  1. #1
    Mats Samson
    Guest

    Using arrays to create Combobox items

    Hello out there!
    I want to use the same items several times in different comboboxes, i.e.
    a currency selection (EUR, USD, SEK, DKK......). There are 7 instances where
    the user selects the currency to use (and it can be different currency at
    every selection). Instead of reading the list from a sheet or writing the
    same ComboboX.AddItem= "EUR" and so on for every new combobox, I wanted to
    use an array and a for...next loop that can be used for every combobox
    creation. But, arrays are not allowed in for...next statements.
    Can it be done in another neat way?
    Best regards
    Mats

  2. #2
    Dick Kusleika
    Guest

    Re: Using arrays to create Combobox items

    Mats

    You can assign an array directly to the List property, so no need for
    For/Next.

    Dim vaCurrency As Variant

    vaCurrency = Array("EUR", "USD", "SEK", "DKK")

    Me.ComboBox1.List = vaCurrency

    Make vaCurrency a global variable and you can use it wherever you want.

    --
    **** Kusleika
    Excel MVP
    Daily Dose of Excel
    www.*****-blog.com

    Mats Samson wrote:
    > Hello out there!
    > I want to use the same items several times in different comboboxes,
    > i.e.
    > a currency selection (EUR, USD, SEK, DKK......). There are 7
    > instances where the user selects the currency to use (and it can be
    > different currency at every selection). Instead of reading the list
    > from a sheet or writing the same ComboboX.AddItem= "EUR" and so on
    > for every new combobox, I wanted to use an array and a for...next
    > loop that can be used for every combobox creation. But, arrays are
    > not allowed in for...next statements.
    > Can it be done in another neat way?
    > Best regards
    > Mats




  3. #3
    Mats Samson
    Guest

    Re: Using arrays to create Combobox items

    Thanks ****!
    It helped and was as simple and neat as you could ask for!
    Best regards
    Mats

    "**** Kusleika" wrote:

    > Mats
    >
    > You can assign an array directly to the List property, so no need for
    > For/Next.
    >
    > Dim vaCurrency As Variant
    >
    > vaCurrency = Array("EUR", "USD", "SEK", "DKK")
    >
    > Me.ComboBox1.List = vaCurrency
    >
    > Make vaCurrency a global variable and you can use it wherever you want.
    >
    > --
    > **** Kusleika
    > Excel MVP
    > Daily Dose of Excel
    > www.*****-blog.com
    >
    > Mats Samson wrote:
    > > Hello out there!
    > > I want to use the same items several times in different comboboxes,
    > > i.e.
    > > a currency selection (EUR, USD, SEK, DKK......). There are 7
    > > instances where the user selects the currency to use (and it can be
    > > different currency at every selection). Instead of reading the list
    > > from a sheet or writing the same ComboboX.AddItem= "EUR" and so on
    > > for every new combobox, I wanted to use an array and a for...next
    > > loop that can be used for every combobox creation. But, arrays are
    > > not allowed in for...next statements.
    > > Can it be done in another neat way?
    > > Best regards
    > > Mats

    >
    >
    >


+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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