+ Reply to Thread
Results 1 to 25 of 25

Message Boxes in Reset Macro

  1. #1
    Forum Contributor
    Join Date
    08-22-2011
    Location
    Texas, United States
    MS-Off Ver
    Excel 2007 and 2010
    Posts
    516

    Message Boxes in Reset Macro

    Hi All,

    I have a reset macro here, that is working great. I only have one problem with it and i cannot seem to find a solution. My problem is that when i run this reset macro it is clearing all the contents that the user has inputed into this workbook, it is displaying the message boxes that are on the other pages of my workbook. On the pages "Loss Development Factors" and "Claim Count - Credibility" i have message boxes that pop up when the user opens the page that tell the user to only paste values on this sheet. when my reset macro is running for some reason it is popping those boxes up and i have to click okay a couple of times to keep the macro going. I think there may be something i have to do on the other pages but here is my reset macro along with one of the pages that shows a message box. The other page is exactly the same. I am a VBA newbie so if you could please explain a solution in pretty good detail so i can understand it. Thanks in advance for all of the help.

    Here is the reset macro
    Please Login or Register  to view this content.
    Here is the pop up box that is on both of the pages listed above
    Please Login or Register  to view this content.

  2. #2
    Forum Expert
    Join Date
    07-16-2010
    Location
    Northumberland, UK
    MS-Off Ver
    Excel 2007 (home), Excel 2010 (work)
    Posts
    3,054

    Re: Message Boxes in Reset Macro

    In your reset macro you have several select statements. These will activate the sheet you're working with, and that in turn will call the worksheet_active event, running the other code.

    Either:

    a) Remove the select statements from the reset macro, or

    b) Add the lines:

    Please Login or Register  to view this content.
    And

    Please Login or Register  to view this content.
    To the reset macro - they can go immediately after the two application.screenupdating lines.

  3. #3
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Message Boxes in Reset Macro

    this looks kinda like this question: http://www.excelforum.com/excel-prog...-updating.html
    what's different?
    Josie

    if at first you don't succeed try doing it the way your wife told you to

  4. #4
    Forum Contributor
    Join Date
    08-22-2011
    Location
    Texas, United States
    MS-Off Ver
    Excel 2007 and 2010
    Posts
    516

    Re: Message Boxes in Reset Macro

    Now it is giving me an error on the .Select line

  5. #5
    Forum Contributor
    Join Date
    08-22-2011
    Location
    Texas, United States
    MS-Off Ver
    Excel 2007 and 2010
    Posts
    516

    Re: Message Boxes in Reset Macro

    Quote Originally Posted by JosephP View Post
    this looks kinda like this question: http://www.excelforum.com/excel-prog...-updating.html
    what's different?
    It is pretty similar, but i am trying to go about the project a little differently

  6. #6
    Forum Expert
    Join Date
    07-16-2010
    Location
    Northumberland, UK
    MS-Off Ver
    Excel 2007 (home), Excel 2010 (work)
    Posts
    3,054

    Re: Message Boxes in Reset Macro

    What error?

  7. #7
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Message Boxes in Reset Macro

    what error and why do you need to select those sheets?

  8. #8
    Forum Contributor
    Join Date
    08-22-2011
    Location
    Texas, United States
    MS-Off Ver
    Excel 2007 and 2010
    Posts
    516

    Re: Message Boxes in Reset Macro

    Quote Originally Posted by JosephP View Post
    what error and why do you need to select those sheets?
    Runtime error '1004:' Select method of worksheet class failed. I am selecting those cells so when the user returns to the page they will know where to start.

  9. #9
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Message Boxes in Reset Macro

    is the sheet visible?

  10. #10
    Forum Contributor
    Join Date
    08-22-2011
    Location
    Texas, United States
    MS-Off Ver
    Excel 2007 and 2010
    Posts
    516

    Re: Message Boxes in Reset Macro

    The sheet is only visible when this is true, Range("A8").FormulaR1C1 = "Rate Indication", which is my first line of code in the reset macro. what it does is changes cell A8 on the first page to "Rate Indication" that then will unhide all the sheets below i am trying to reset.

  11. #11
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Message Boxes in Reset Macro

    yeah but is it actually visible when that line runs?

  12. #12
    Forum Expert
    Join Date
    07-16-2010
    Location
    Northumberland, UK
    MS-Off Ver
    Excel 2007 (home), Excel 2010 (work)
    Posts
    3,054

    Re: Message Boxes in Reset Macro

    Move the line:

    Please Login or Register  to view this content.
    To immediately after the line where you set cell A8 to "Rate Indication"

  13. #13
    Forum Contributor
    Join Date
    08-22-2011
    Location
    Texas, United States
    MS-Off Ver
    Excel 2007 and 2010
    Posts
    516

    Re: Message Boxes in Reset Macro

    It may be visible it may not, depending on what the user has put in cell A8 on the first sheet. if it is blank then it is not visible, if it has contents then it is. I have tried it both ways but i still get the same runtime error. This works without the select lines, so i am not sure why the select lines are throwing it off.
    Last edited by amotto11; 05-29-2012 at 10:56 AM.

  14. #14
    Forum Contributor
    Join Date
    08-22-2011
    Location
    Texas, United States
    MS-Off Ver
    Excel 2007 and 2010
    Posts
    516

    Re: Message Boxes in Reset Macro

    Quote Originally Posted by Andrew-R View Post
    Move the line:

    Please Login or Register  to view this content.
    To immediately after the line where you set cell A8 to "Rate Indication"

    Okay so now i have this and it is giving me an error on the last .Select in my code. I think it is almost there i got past all of the other .Selects
    Please Login or Register  to view this content.

  15. #15
    Forum Expert
    Join Date
    07-16-2010
    Location
    Northumberland, UK
    MS-Off Ver
    Excel 2007 (home), Excel 2010 (work)
    Posts
    3,054

    Re: Message Boxes in Reset Macro

    So is the sheet "Loss Ratio Proj Instructions" visible?

  16. #16
    Forum Contributor
    Join Date
    08-22-2011
    Location
    Texas, United States
    MS-Off Ver
    Excel 2007 and 2010
    Posts
    516

    Re: Message Boxes in Reset Macro

    Quote Originally Posted by Andrew-R View Post
    So is the sheet "Loss Ratio Proj Instructions" visible?
    When the cell A8 on selections contains "Rate Indication" then the 'Rate Indication Instructions', 'Loss Development Factors', 'Claim Count - Credibility', and 'Summary' Sheets are all visible. When cell A8 on 'Selections' says "Loss Ratio Projection" then the sheets 'Loss Ratio Proj Instructions', 'Loss Development Factors', 'Claim Count - Credibility', and 'Summary' Sheets are all visible. The worksheet is to do two different things just depending on what the user wants to do. that is why i have to go back to A8 on the 'Selections' sheet and change the name from one thing to another in my reset macro above, to make the sheet visible then clear the contents. I hope i am being clear enough. Thank you all again.

  17. #17
    Forum Expert
    Join Date
    07-16-2010
    Location
    Northumberland, UK
    MS-Off Ver
    Excel 2007 (home), Excel 2010 (work)
    Posts
    3,054

    Re: Message Boxes in Reset Macro

    Ah, I hadn't seen you'd changed the value in A8 mid-macro.

    Before you do that change you need to set Application.EnableEvents to True, and then set it back to False after you've changed that cell.

    This is really, really terrible coding, and we should do this properly, but it's a hot and stuffy afternoon in my office and I've lost the will to live

  18. #18
    Forum Contributor
    Join Date
    08-22-2011
    Location
    Texas, United States
    MS-Off Ver
    Excel 2007 and 2010
    Posts
    516

    Re: Message Boxes in Reset Macro

    Quote Originally Posted by Andrew-R View Post
    Ah, I hadn't seen you'd changed the value in A8 mid-macro.

    Before you do that change you need to set Application.EnableEvents to True, and then set it back to False after you've changed that cell.

    This is really, really terrible coding, and we should do this properly, but it's a hot and stuffy afternoon in my office and I've lost the will to live
    Haha, I figured it was bad coding, but i am very very new to VBA and all i did was record myself then clean it up a little. Is it at all posible could you post my code with your changes in the correct places, just the EnableEvents lines. Thanks so much

  19. #19
    Forum Expert
    Join Date
    07-16-2010
    Location
    Northumberland, UK
    MS-Off Ver
    Excel 2007 (home), Excel 2010 (work)
    Posts
    3,054

    Re: Message Boxes in Reset Macro

    Try this:

    Please Login or Register  to view this content.
    However, if my copy of "Professional Excel Development" attacks me I'm holding you personally responsible

  20. #20
    Forum Contributor
    Join Date
    08-22-2011
    Location
    Texas, United States
    MS-Off Ver
    Excel 2007 and 2010
    Posts
    516

    Re: Message Boxes in Reset Macro

    Okay, now It is ending on the page 'Loss Ratio Proj Instructions', I would like it to end as you can see on the page 'Selection' with A8 being "", so that all of the other sheets will be hidden and the user can restart the project. I think i may need another one of thoseEnableEvents lines somewhere. Thanks
    Last edited by amotto11; 05-29-2012 at 11:28 AM.

  21. #21
    Forum Expert
    Join Date
    07-16-2010
    Location
    Northumberland, UK
    MS-Off Ver
    Excel 2007 (home), Excel 2010 (work)
    Posts
    3,054

    Re: Message Boxes in Reset Macro

    I can see the finish line from here ...

    Please Login or Register  to view this content.

  22. #22
    Forum Contributor
    Join Date
    08-22-2011
    Location
    Texas, United States
    MS-Off Ver
    Excel 2007 and 2010
    Posts
    516

    Re: Message Boxes in Reset Macro

    Quote Originally Posted by Andrew-R View Post
    I can see the finish line from here ...
    Haha, Unfortunatly i am now getting those stubborn boxes popping up again. hah, this is so frustrating. It seems to be back at square one.

  23. #23
    Forum Expert
    Join Date
    07-16-2010
    Location
    Northumberland, UK
    MS-Off Ver
    Excel 2007 (home), Excel 2010 (work)
    Posts
    3,054

    Re: Message Boxes in Reset Macro

    One more try:

    Please Login or Register  to view this content.
    I may have made too many sheets hidden there, but you can take out the .Visible = False lines as required.

  24. #24
    Forum Contributor
    Join Date
    08-22-2011
    Location
    Texas, United States
    MS-Off Ver
    Excel 2007 and 2010
    Posts
    516

    Re: Message Boxes in Reset Macro

    Quote Originally Posted by Andrew-R View Post
    One more try:

    I may have made too many sheets hidden there, but you can take out the .Visible = False lines as required.
    Okay, I see what you are doing. Now, after the reset runs it is showing 'Selection', 'Loss Development Factors', 'Claim Count - Credibility', and 'Summary'. The only sheet i want to show is 'Selection' and that is what it should be doing when A8 on 'Selection' is "", I am not sure why it isn't doing this. Is there more .Visible statements i can put at the end of the code to just force them to not be visible. The only sheet i want to be visible is 'Selection'. Thanks

  25. #25
    Forum Contributor
    Join Date
    08-22-2011
    Location
    Texas, United States
    MS-Off Ver
    Excel 2007 and 2010
    Posts
    516

    Re: Message Boxes in Reset Macro

    I think i got it. All i did was add some lines to the bottom of the code to force the sheets to not be visible. I think this should work, Please let me know if you think in the long run you have a better solution or something looks kind of fishy with my code. Thank you all so much for all the help, Andrew-P especially.

    Please Login or Register  to view this content.

+ 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