+ Reply to Thread
Results 1 to 5 of 5

event handling froma userform

  1. #1
    Forum Contributor
    Join Date
    12-15-2008
    Location
    Oxfordshire, UK
    MS-Off Ver
    2007.
    Posts
    100

    event handling froma userform

    Hi All,

    I have a little problem with a userform commandbutton that I cannot resolve. I cannot seem to excecute a macro from a commandbutton, but if I go to the VBA project I can get it to work from there.

    The cmb just calls a macro, which in itself call 5 other macros. This is the code for the button:
    Please Login or Register  to view this content.
    I may be missign something really simple here. As I said, if I go to the code and run it from there it opens the userform, I select a value and then click OK and it works, but it will not work if running from excel.
    Any ideas?

    JD
    Last edited by jad70; 03-10-2009 at 09:15 AM.

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: event handling froma userform

    Hello JD,

    Your code as shown is correct. It probably is something simple. It will easier and faster to find the problem if you post your workbook.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Forum Contributor
    Join Date
    12-15-2008
    Location
    Oxfordshire, UK
    MS-Off Ver
    2007.
    Posts
    100

    Re: event handling froma userform

    Leith,

    Attached is the workbook as is with only some text deleted.

    My problem is this-
    If I click on 'View All Tasks' on the info sheet, the sheet all tasks is shown. If you then delete the content in H3,4 and 5, then go back to the info sheet and click 'select Nation' the userform presents itself. If you select a Nation and then click OK, the values in H3,4 and 5 should appear. Currently they do not. But, if you select 'Update Tasks' and close the dataform, the cells values will re-appear, The close button on the dataform calls the same macro as the OK button on te Nation userform. I am a bit puzzled...
    All the macros are described as to what they do.

    Many thanks.
    JD
    Attached Files Attached Files

  4. #4
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,431

    Re: event handling froma userform

    Your code references the Activesheet, which is "Infromation" when the code is run.

    The simplest fix is to activate the correct sheet. The more robust solution is to alter your code to use full references.

    Please Login or Register  to view this content.
    Cheers
    Andy
    www.andypope.info

  5. #5
    Forum Contributor
    Join Date
    12-15-2008
    Location
    Oxfordshire, UK
    MS-Off Ver
    2007.
    Posts
    100

    Re: event handling froma userform

    Andy,Leith

    Apologies for not posting a reply earlier.

    I came in this morning with a clear head and figured out that I had not selected the sheet for the code to run on. The reason it ran on the dataform closure is that the sheet was already activated.

    I solved this a little differently, in that with the OK button I now have this:-

    Please Login or Register  to view this content.
    The reason to make the sheet hidden is because however I configure the screen updating, if I select another option button with sheet1 visible the screeen jumps to sheet1 and then back again. Might not be perfect but it works.
    and for the All Update code I have this:-

    Please Login or Register  to view this content.
    It has the same result though.

    Many thanks again.

    JD

+ 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