+ Reply to Thread
Results 1 to 8 of 8

Command Button Error

  1. #1
    Registered User
    Join Date
    11-29-2012
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    20

    Command Button Error

    I have a spreadsheet with multiple macros. Two of the command button macros are giving me a hard time. When I click on them they cause the screen to flicker and will not let me do anything in the file. Then when I hit the Alt key my macro runs. This makes no sence to me. I have multiple copies of this document as I make mistakes from time to time and I don't want to screw up my original. The problem is that I just made two days worth of changes to my document and now it is giving my a hard time. I do not want to go through making all these changes again if I do not have to.

    I do not think that the changes have anything to do with the error as these command buttons bring up message boxes asking me if I am sure I want to run that specific macro. In other words it is screwing up before the macro even fully runs or needs to do anything within the changed document. That is why I am lost! Any suggestions? I have already tried copying and pasting the macros from the original document over to the new one and that does nothing.

    Thank you in advance!

  2. #2
    Forum Contributor
    Join Date
    07-26-2012
    Location
    USA
    MS-Off Ver
    Excel 2007 & 2010
    Posts
    351

    Re: Command Button Error

    As for the screen flickering, put Application.ScreenUpdating = False at the beginning of your code. As for it not running properly, can you paste your code? The changes you made most likely have to do with the error, especially if it was working fine before you made said changes.
    Last edited by VBA FTW; 11-30-2012 at 11:46 AM.

  3. #3
    Registered User
    Join Date
    11-29-2012
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    20

    Re: Command Button Error

    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    11-29-2012
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    20

    Re: Command Button Error

    I understand why making changes to my document would cause problems except once I use the Alt key to brin my message window to the front of the screen it works fine until I close the file and reopen it. I guess it really isn't a huge deal as I know what to do to get it to work, I just think it should work without hitting the Alt key and I'm not even sure what the Alt key has to do with it anyway...

    Thanks for taking a look at it!

  5. #5
    Forum Contributor
    Join Date
    07-26-2012
    Location
    USA
    MS-Off Ver
    Excel 2007 & 2010
    Posts
    351

    Re: Command Button Error

    Can I ask, is there any reason this needs to be an event macro? Can you not put this code into a module rather than a worksheet object? Also, maybe I'm interpretting your filename wrong, but you can't save a file with "\" in the filename

  6. #6
    Registered User
    Join Date
    11-29-2012
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    20

    Re: Command Button Error

    To be honest I do not know if I know how to do that... Basicly this command is shifting an entire rown of cells down on one worksheet, then saving the document, then hiding two worksheets, and resaving the spreadsheet under a new name and in a new location that is chosen from certain cells in the worksheet.

    Also can you show me where to put that code at the beining of my macro to stop the screen flickering?

    Thanks!

  7. #7
    Forum Contributor
    Join Date
    07-26-2012
    Location
    USA
    MS-Off Ver
    Excel 2007 & 2010
    Posts
    351

    Re: Command Button Error

    Inserting a module is a piece of cake. In the Vb editor, right click on "Microsoft Excel Objects", click "Insert", "Module". Then try pasting the below code into the module. Then right click on your form control button on your spreadsheet, click "Assign", and choose CommandButton3_Click. I haven't tested this code out, but give it a try. However, if you're saving your file name like something similar to this: "A2 G2\ G2 11.30.12" I don't think the macro will work because you cannot save a file with a "\" in the file name. Can you use "_" instead of "\" in the file name? It may help if you could post an example of how the file name should look. Also, what is Macro4?
    Please Login or Register  to view this content.
    Last edited by VBA FTW; 11-30-2012 at 03:22 PM.

  8. #8
    Registered User
    Join Date
    11-29-2012
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    20

    Re: Command Button Error

    I appoligize for not clarifying the "/" in my previous reply. The reason for the "/" in the code is because it is pulling info from the spreadsheet to place the newly saved file in different folders and sub folders based upon the information in the cells.

    I think that placing the Application.ScreenUpdating = False at the begning of my code has soved not only the flickering but also the problem for having to hit the Alt key everytime I want to run code...

    I' going to keep my fingers crossed! Thanks for all your help!

+ 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