Results 1 to 10 of 10

Thread: Excel / VBA Combo Box

  1. #1
    HEXUS.social member Disturbedguy's Avatar
    Join Date
    Nov 2006
    Location
    Manchester
    Posts
    5,113
    Thanks
    841
    Thanked
    482 times in 357 posts
    • Disturbedguy's system
      • Motherboard:
      • Asus Rog Strix Z370-H Gaming
      • CPU:
      • i7 8700K
      • Memory:
      • 16GB Corsair something or other
      • Storage:
      • 1 x Samsung 960 EVO (250GB) 1 x Samsung 850 EVO (500GB)
      • Graphics card(s):
      • GTX 1080Ti
      • Operating System:
      • Windows 7 Ultimate
      • Monitor(s):
      • 32inch Samsung TV
      • Internet:
      • Crap

    Excel / VBA Combo Box

    Hi all,

    Me again, thanks for the help last time, much appreciated, however, new problem time.

    I have a ComboBox on a form that will list a number of options, I was hoping / would like it so that when one of the options is selected it opens the relevant form either automatically or on the press of a button.

    Have been searching this morning and my google-fu has been weak as such I haven't been able to find anything yet.

    Bit of background / information - I was originally going to have buttons to open each form, but soon realised that having the number of buttons I would require for the sites we have (about 115) would look messy so it was decided a dropdown could be an idea.

    We did look at the idea of having a search function on the form, users then enter either the depot number (3 digit) or depot name, click the search button and it opens the relevant form, but I am completely clueless in this regards.

    Again, appreciate any help I receive.
    Quote Originally Posted by TAKTAK View Post
    It didn't fall off, it merely became insufficient at it's purpose and got a bit droopy...

  2. #2
    HEXUS.social member Disturbedguy's Avatar
    Join Date
    Nov 2006
    Location
    Manchester
    Posts
    5,113
    Thanks
    841
    Thanked
    482 times in 357 posts
    • Disturbedguy's system
      • Motherboard:
      • Asus Rog Strix Z370-H Gaming
      • CPU:
      • i7 8700K
      • Memory:
      • 16GB Corsair something or other
      • Storage:
      • 1 x Samsung 960 EVO (250GB) 1 x Samsung 850 EVO (500GB)
      • Graphics card(s):
      • GTX 1080Ti
      • Operating System:
      • Windows 7 Ultimate
      • Monitor(s):
      • 32inch Samsung TV
      • Internet:
      • Crap

    Re: Excel / VBA Combo Box

    Nevermind guys, after re-alignign my chi, I found what i was looking for -

    Private Sub DepotSelect_Change()
    Select Case DepotSelect.Value
    Case "Ford"
    frmFord.Show
    Case "Leatherhead"
    frmLeatherhead.Show

    End Select

    End Sub

    And that works, I select an option and wallah the form opens
    Quote Originally Posted by TAKTAK View Post
    It didn't fall off, it merely became insufficient at it's purpose and got a bit droopy...

  3. #3
    HEXUS.social member Disturbedguy's Avatar
    Join Date
    Nov 2006
    Location
    Manchester
    Posts
    5,113
    Thanks
    841
    Thanked
    482 times in 357 posts
    • Disturbedguy's system
      • Motherboard:
      • Asus Rog Strix Z370-H Gaming
      • CPU:
      • i7 8700K
      • Memory:
      • 16GB Corsair something or other
      • Storage:
      • 1 x Samsung 960 EVO (250GB) 1 x Samsung 850 EVO (500GB)
      • Graphics card(s):
      • GTX 1080Ti
      • Operating System:
      • Windows 7 Ultimate
      • Monitor(s):
      • 32inch Samsung TV
      • Internet:
      • Crap

    Re: Excel / VBA Combo Box

    *sigh* only slightly resolved.

    It appears, unless I am being stupid that there is a limit to the number of items I can have on a line on VBA with a combo box before it drops to a new line and no longer recognises the data I am inputting as part of the same combo box, therefore meaning I can't get the combo box to list all the items I have.

    Does anyone know if there is a limit and if so, is there a way around this?
    Quote Originally Posted by TAKTAK View Post
    It didn't fall off, it merely became insufficient at it's purpose and got a bit droopy...

  4. #4
    Not a good person scaryjim's Avatar
    Join Date
    Jan 2009
    Location
    Gateshead
    Posts
    15,196
    Thanks
    1,231
    Thanked
    2,291 times in 1,874 posts
    • scaryjim's system
      • Motherboard:
      • Dell Inspiron
      • CPU:
      • Core i5 8250U
      • Memory:
      • 2x 4GB DDR4 2666
      • Storage:
      • 128GB M.2 SSD + 1TB HDD
      • Graphics card(s):
      • Radeon R5 230
      • PSU:
      • Battery/Dell brick
      • Case:
      • Dell Inspiron 5570
      • Operating System:
      • Windows 10
      • Monitor(s):
      • 15" 1080p laptop panel

    Re: Excel / VBA Combo Box

    how do you mean number of items on a line? A combo box should theoretically be able to hold as many items as you throw at it. How are you setting up the combo box?

  5. #5
    HEXUS.social member Disturbedguy's Avatar
    Join Date
    Nov 2006
    Location
    Manchester
    Posts
    5,113
    Thanks
    841
    Thanked
    482 times in 357 posts
    • Disturbedguy's system
      • Motherboard:
      • Asus Rog Strix Z370-H Gaming
      • CPU:
      • i7 8700K
      • Memory:
      • 16GB Corsair something or other
      • Storage:
      • 1 x Samsung 960 EVO (250GB) 1 x Samsung 850 EVO (500GB)
      • Graphics card(s):
      • GTX 1080Ti
      • Operating System:
      • Windows 7 Ultimate
      • Monitor(s):
      • 32inch Samsung TV
      • Internet:
      • Crap

    Re: Excel / VBA Combo Box

    Hmm sorry I didn't really explain myself properly, when adding items intot he combobox within the VBA, it appears I am limited to how much I can put on a single line, before it jumps to the next, therefore breaking what I have entered so at the moment I can't add all the items to the combo box correctly.

    DepotSelect.List = Array("780:Aberdeen", "AvonmouthPA", "984:Balfour Beatty", "158:Barking") - There is more than this, this is just a selection
    Quote Originally Posted by TAKTAK View Post
    It didn't fall off, it merely became insufficient at it's purpose and got a bit droopy...

  6. #6
    HEXUS.social member Disturbedguy's Avatar
    Join Date
    Nov 2006
    Location
    Manchester
    Posts
    5,113
    Thanks
    841
    Thanked
    482 times in 357 posts
    • Disturbedguy's system
      • Motherboard:
      • Asus Rog Strix Z370-H Gaming
      • CPU:
      • i7 8700K
      • Memory:
      • 16GB Corsair something or other
      • Storage:
      • 1 x Samsung 960 EVO (250GB) 1 x Samsung 850 EVO (500GB)
      • Graphics card(s):
      • GTX 1080Ti
      • Operating System:
      • Windows 7 Ultimate
      • Monitor(s):
      • 32inch Samsung TV
      • Internet:
      • Crap

    Re: Excel / VBA Combo Box

    Fixed. Issue was length of function exceeded max, used the line continuation thing ( _) - space followed by underscore to break up the lines, working fine.
    Quote Originally Posted by TAKTAK View Post
    It didn't fall off, it merely became insufficient at it's purpose and got a bit droopy...

  7. #7
    Seething Cauldron of Hatred TheAnimus's Avatar
    Join Date
    Aug 2005
    Posts
    17,168
    Thanks
    803
    Thanked
    2,152 times in 1,408 posts

    Re: Excel / VBA Combo Box

    try something like
    Code:
    DepotSelect.List = Array("780:Aberdeen", "AvonmouthPA",  _
    "984:Balfour Beatty", "158:Barking")
    What you are fighting is the word wrapping behaviour. 'Grown up' languages often use a ; to terminate a line, this makes it very easy to know when one ends. Historical reasons make newline (often \n or \r\n depending) tricky, so VBA squeels like an italian PM in a whorehouse should you try. the _ char means I'll continue on a new line.
    throw new ArgumentException (String, String, Exception)

  8. Received thanks from:

    Disturbedguy (25-06-2013)

  9. #8
    HEXUS.social member Disturbedguy's Avatar
    Join Date
    Nov 2006
    Location
    Manchester
    Posts
    5,113
    Thanks
    841
    Thanked
    482 times in 357 posts
    • Disturbedguy's system
      • Motherboard:
      • Asus Rog Strix Z370-H Gaming
      • CPU:
      • i7 8700K
      • Memory:
      • 16GB Corsair something or other
      • Storage:
      • 1 x Samsung 960 EVO (250GB) 1 x Samsung 850 EVO (500GB)
      • Graphics card(s):
      • GTX 1080Ti
      • Operating System:
      • Windows 7 Ultimate
      • Monitor(s):
      • 32inch Samsung TV
      • Internet:
      • Crap

    Re: Excel / VBA Combo Box

    Quote Originally Posted by TheAnimus View Post
    try something like
    Code:
    DepotSelect.List = Array("780:Aberdeen", "AvonmouthPA",  _
    "984:Balfour Beatty", "158:Barking")
    What you are fighting is the word wrapping behaviour. 'Grown up' languages often use a ; to terminate a line, this makes it very easy to know when one ends. Historical reasons make newline (often \n or \r\n depending) tricky, so VBA squeels like an italian PM in a whorehouse should you try. the _ char means I'll continue on a new line.
    Thanks for the explanation.

    I remember seeing and using the ; when messing with js / node.js a little recently-ish...really is something I need to sit down and put my backside into learning.
    Quote Originally Posted by TAKTAK View Post
    It didn't fall off, it merely became insufficient at it's purpose and got a bit droopy...

  10. #9
    Seething Cauldron of Hatred TheAnimus's Avatar
    Join Date
    Aug 2005
    Posts
    17,168
    Thanks
    803
    Thanked
    2,152 times in 1,408 posts

    Re: Excel / VBA Combo Box

    I'll drop you the invoice later today
    throw new ArgumentException (String, String, Exception)

  11. #10
    HEXUS.social member Disturbedguy's Avatar
    Join Date
    Nov 2006
    Location
    Manchester
    Posts
    5,113
    Thanks
    841
    Thanked
    482 times in 357 posts
    • Disturbedguy's system
      • Motherboard:
      • Asus Rog Strix Z370-H Gaming
      • CPU:
      • i7 8700K
      • Memory:
      • 16GB Corsair something or other
      • Storage:
      • 1 x Samsung 960 EVO (250GB) 1 x Samsung 850 EVO (500GB)
      • Graphics card(s):
      • GTX 1080Ti
      • Operating System:
      • Windows 7 Ultimate
      • Monitor(s):
      • 32inch Samsung TV
      • Internet:
      • Crap

    Re: Excel / VBA Combo Box

    I'll be sure to pass it onto my boss
    Quote Originally Posted by TAKTAK View Post
    It didn't fall off, it merely became insufficient at it's purpose and got a bit droopy...

Thread Information

Users Browsing this Thread

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

Posting Permissions

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