Automatically increment the numbering of a ComboBox

cestsupergenial Posted messages 18 Status Member -  
cestsupergenial Posted messages 18 Status Member -
Hello everyone,
I have a beginner's question that should have a simple answer, but I haven't found it!
I created several ComboBoxes in a UserForm, which call macros. These macros are identical for all the ComboBoxes, with the exception that they depend on the selected ComboBox: they follow the structure If UserForm1.ComboBox1.Value="a" Then..., this pattern repeating many times.
How can I add a few lines of code so that this macro also applies to ComboBox2, 3, etc.?
(The brute-force solution I have for now has been to create another macro by changing the number of the ComboBox, but I'm open to reducing the length of my code by half!)

3 answers

  1. eriiic Posted messages 24581 Registration date   Status Contributor Last intervention   7 281
     
    Hello,

    Without code or file, it's difficult to get a clear idea of the problem...
    You could very well have a common procedure that you call from the different comboboxes, possibly with some parameters passed.
    eric

    --
    By continuously trying, we eventually succeed.
    So the more it fails, the more chances we have that it will work. (the Shadoks)
    In addition to the thank you (yes, it does happen!!!), please remember to mark it as resolved. Thank you.
    0
  2. cestsupergenial Posted messages 18 Status Member
     
    Thank you for your advice! I didn't manage to do exactly what I wanted, but I found a small workaround that saves me a lot of space in my code (and a few hours as well!).
    0