Consulting

Page 1 of 2 1 2 LastLast
Results 1 to 20 of 39

Thread: Assign macro to combobox selections

  1. #1

    Assign macro to combobox selections

    Hi all, Im brand new here, and a bit of a novice when it come to macros and VB...
    I need to assign a combobox to macros
    Ive tried everythng I can think of but with no success!!!
    I cannot get this formula to work can anyone assist?
    I have this in a different module to where tha actual macros are. Is this correct? (although I?ve tried both)
    Thanks
    legepe

    [VBA]
    Private Sub ComboBox64_Change()
    Select Case Me.ComboBox64.Value

    Case "ENE"
    Macro1

    Case "FEB"
    Macro2

    Case "MAR"
    Macro3

    End Select
    End Sub
    [/VBA]

  2. #2
    VBAX Contributor compariniaa's Avatar
    Joined
    Jun 2006
    Location
    Santa Clarita, CA
    Posts
    117
    Location
    How did you create your combobox? from the Forms toolbar, or the Control Toolbox toolbar?

  3. #3
    VBAX Contributor compariniaa's Avatar
    Joined
    Jun 2006
    Location
    Santa Clarita, CA
    Posts
    117
    Location
    or is it in a userform?

  4. #4
    I think it is the forms tool bar
    The one at the top of the screen

  5. #5
    VBAX Contributor compariniaa's Avatar
    Joined
    Jun 2006
    Location
    Santa Clarita, CA
    Posts
    117
    Location
    if you made it using the forms toolbar and it's embedded in a sheet, i can't see any reason why you wouldn't be able to assign a macro to it. but if it was made with the control toolbox or if it's in a userform, right-click the box, click "View Code" and copy and paste your code in there

  6. #6
    I can assign a macro to the combobox, but I have 12 macros and 12 values in the combobox - each one must be assigned independantly
    The only thing that I can get to work is one macro (one of the 12) And no matter which value I click on it just uses the one macro

  7. #7
    The code in View Code is where it is linked to the values that are in the combobox, I do not understand why or where i need to copy these to?

  8. #8
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Quote Originally Posted by legepe
    I can assign a macro to the combobox, but I have 12 macros and 12 values in the combobox - each one must be assigned independantly
    The only thing that I can get to work is one macro (one of the 12) And no matter which value I click on it just uses the one macro
    Link the comobox to a cell, the selected index then goes in that cell. In your macro, test which value is in the cell, and use that to index into the list you use to poulate the combobox, you can then call the macro based upon that value.

  9. #9
    Moderator VBAX Wizard lucas's Avatar
    Joined
    Jun 2004
    Location
    Tulsa, Oklahoma
    Posts
    7,323
    Location
    Hi legepe,
    I have edited your post to reflect the question you are asking. Please help isn't very descriptive of your problem. I also added vba tags to your code in your first post....select your code when posting and hit the vba button. It makes your code easier to read.

    I would suggest that you upload a sample of your spreadsheet so that others can look at it and see what is going on, it makes it easier to understand your problem.
    Steve
    "Nearly all men can stand adversity, but if you want to test a man's character, give him power."
    -Abraham Lincoln

  10. #10

    File upload

    Thanks for all your replies... and your comments
    I have tried to upload the spread sheet its in Gif format, but way to big to post here
    Can you tell me the best format to do this in?
    legepe

  11. #11
    VBAX Contributor compariniaa's Avatar
    Joined
    Jun 2006
    Location
    Santa Clarita, CA
    Posts
    117
    Location
    you could zip it, or just post the workbook itself. if the workbook is too big just take some rows off...we just need to get an idea, not necessarily an exact picture

  12. #12
    Please see attached file

    I am working with a spanish version of excel which is making things more difficult!

    1. I have doubts about the name of the "combobox" This is displayed in the top left hand side of the screen when I right click on the combobox, Secondly the name displayed in the box is - Lista desplegable 64 - why 64, I do not have any more comboboxes attached to the sheet?

    2. The 12 macros that I have made are for the blue tabs you see at the bottom of the screen shot

    3. I need a way to link these 12 macros to each of the tabs, so that when I open the combobox and click on JUN for example, it will take me to that sheet.

    I hope that this is clear, and I am hoping that someone can help me?

    Thanks a lot

    legepe

  13. #13
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Post the workbook, not a picture of it.

  14. #14
    I think I must be misunderstanding - the workbook is far to large
    How can I post it?

  15. #15
    Ive done it !!!
    Please find the attached workbook
    Hope you can help
    Thanks
    legepe

  16. #16
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Exactly as I said earlier

  17. #17
    Thats Fantastic!!
    Can you believe that I?ve spent 4 days trying to figure that out
    Thanks a lot
    legepe

  18. #18
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    You should have posted earlier, it took me 10 mins.

  19. #19
    Well, Ill know next time
    Thanks again!!
    Can

  20. #20
    ---Can you recommend a good way of learning VB... may be a book but for dummies!!!

Posting Permissions

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