Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Visual Basic Code in Excel Macro

Visual Basic Code in Excel Macro

Scheduled Pinned Locked Moved Visual Basic
helpquestion
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Ahmad Rifai Yusuf
    wrote on last edited by
    #1

    Dear all, Here I attach my Visual Basic Code for Combo Box Control runs in Microsoft Excel Macro, but once the object is run and I click this object control the item will increase continuaously. Wheather any of you who can asisst me solve this problem..? :cool::cool:

    Private Sub ComboBox1_Change()
    ComboBox1.AddItem "SIDM"
    ComboBox1.AddItem "BIJ"
    ComboBox1.AddItem "M1D"
    ComboBox1.AddItem "THERESA"
    ComboBox1.AddItem "YS"
    ComboBox1.AddItem "OPTION"
    End Sub

    Best Regards, Ahmad Rifai Yusuf

    W D 2 Replies Last reply
    0
    • A Ahmad Rifai Yusuf

      Dear all, Here I attach my Visual Basic Code for Combo Box Control runs in Microsoft Excel Macro, but once the object is run and I click this object control the item will increase continuaously. Wheather any of you who can asisst me solve this problem..? :cool::cool:

      Private Sub ComboBox1_Change()
      ComboBox1.AddItem "SIDM"
      ComboBox1.AddItem "BIJ"
      ComboBox1.AddItem "M1D"
      ComboBox1.AddItem "THERESA"
      ComboBox1.AddItem "YS"
      ComboBox1.AddItem "OPTION"
      End Sub

      Best Regards, Ahmad Rifai Yusuf

      W Offline
      W Offline
      Wayne Gaylard
      wrote on last edited by
      #2

      I think you really need to think this one through. ComboBox Change event fires everytime there is a change to the contents of the ComboBox, and yet you are adding more items to the ComboBox every time it fires. This will set up a continuous loop, that will run forever. You need to fill the ComboBox only once, and then use the Change event to execute instructions against the selected item.

      1 Reply Last reply
      0
      • A Ahmad Rifai Yusuf

        Dear all, Here I attach my Visual Basic Code for Combo Box Control runs in Microsoft Excel Macro, but once the object is run and I click this object control the item will increase continuaously. Wheather any of you who can asisst me solve this problem..? :cool::cool:

        Private Sub ComboBox1_Change()
        ComboBox1.AddItem "SIDM"
        ComboBox1.AddItem "BIJ"
        ComboBox1.AddItem "M1D"
        ComboBox1.AddItem "THERESA"
        ComboBox1.AddItem "YS"
        ComboBox1.AddItem "OPTION"
        End Sub

        Best Regards, Ahmad Rifai Yusuf

        D Offline
        D Offline
        Dalek Dave
        wrote on last edited by
        #3

        You either need to make this a once only event, a simple flag and IF THEN would do it, or reset the combo box each time. Depending on what you need either is a valid option. ComboBox1.Items.Clear() would do the trick. Otherwise as I say just call the population once at the beginning.

        ------------------------------------ I will never again mention that I was the poster of the One Millionth Lounge Post, nor that it was complete drivel. Dalek Dave CCC League Table Link CCC Link[^]

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups