+ Reply to Thread
Results 1 to 9 of 9

Command Button Not working in new file

  1. #1
    Forum Contributor
    Join Date
    11-11-2013
    Location
    Melbourne, Australia
    MS-Off Ver
    Excel 2010
    Posts
    129

    Command Button Not working in new file

    Hi,

    I'm a bit of a novice when it comes to Macro's and VBA, so I don't know why this is not working...

    I have created 3 Macro's - 1 to Unhide some sheets, 1 to Hide them again once I've viewed them, and 1 to run the Monthly Updates (this is for posting results for each month to month for the directors)

    The first 2 work when I save files from Month to Month, but the 3rd doesn't?? I have to go into VBA and change a few cell references before I run it.

    Is there anything straight forward that I might be missing, or is there anything that I need to post on here for someone to look at?

    Any help is much appreciated

    Thanks,

  2. #2
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 insider Version 2504 Win 11
    Posts
    24,704

    Re: Command Button Not working in new file

    Suggest you post your code here for the one that is not working. Tell us what is not happening that you want to happen.
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  3. #3
    Forum Contributor
    Join Date
    11-11-2013
    Location
    Melbourne, Australia
    MS-Off Ver
    Excel 2010
    Posts
    129

    Re: Command Button Not working in new file

    Well it's a long code, hence I didn't really want to post it at first... (And I can't post all of it, as it's too long!! So I've posted the 2nd half of it in a separate post.)

    Basically it Unhides/Hides/Changes References throught about 20 worksheets in a Workbook. It worked in the October File But when I renamed the file to November and changed some of the column reference in VBA, the command button doesn't work.

    Thanks,

    Please Login or Register  to view this content.
    Last edited by Fletch74; 12-05-2013 at 08:57 PM.

  4. #4
    Forum Contributor
    Join Date
    11-11-2013
    Location
    Melbourne, Australia
    MS-Off Ver
    Excel 2010
    Posts
    129

    Re: Command Button Not working in new file

    Please Login or Register  to view this content.

  5. #5
    Forum Contributor
    Join Date
    11-11-2013
    Location
    Melbourne, Australia
    MS-Off Ver
    Excel 2010
    Posts
    129

    Re: Command Button Not working in new file

    Please Login or Register  to view this content.

  6. #6
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 insider Version 2504 Win 11
    Posts
    24,704

    Re: Command Button Not working in new file

    Are you getting error messages? If so, what is the message and what line of code is highlighted?

    Which lines of code did you change? It is difficult to diagnose a patient if you don't know the symptoms.

  7. #7
    Forum Contributor
    Join Date
    11-11-2013
    Location
    Melbourne, Australia
    MS-Off Ver
    Excel 2010
    Posts
    129

    Re: Command Button Not working in new file

    No, no error messages. It just doesn't respond.

    I changed quite a few lines. Last month I did this and it worked, but I didn't have the command button. I used a Shortcut Ctrl + w. Then I created the command button and it's not working, when it worked last month.

    I just tried the Ctrl + w I get an error "Compile error - Expected End with" With End Sub highlighted if that helps.

  8. #8
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 insider Version 2504 Win 11
    Posts
    24,704

    Re: Command Button Not working in new file

    You have several With.Selection.Interior lines that have no End With. I would start there and see if that resolves your issue. I suspect that when you replaced your lines of code, you may have inadvertently removed them.

    Additionally, if you wish for your code to run more efficiently, you may want to combine lines of code.

    for example, lines like this

    Please Login or Register  to view this content.
    could be replaced with
    Please Login or Register  to view this content.
    and lines like this:
    Please Login or Register  to view this content.
    could be replaced with
    Please Login or Register  to view this content.
    It will take a bit of work to do this, but it will make your code shorter and faster.

    Alan

  9. #9
    Forum Contributor
    Join Date
    11-11-2013
    Location
    Melbourne, Australia
    MS-Off Ver
    Excel 2010
    Posts
    129

    Re: Command Button Not working in new file

    Cheers Alan. Thanks for your help

    I'm not really sure what "End With" means as I just Recorded a Macro to do this. The code was obviously created as a result of that.

    I've copied both last months file and this months file into a spreadsheet. They are identical, so I don't know why they didn't work...

    I will have a look at reducing the lines as you mentioned as well.

    I'm just going to re-save the old file and try again after I change one or two bits of code to see if it works then.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Disable command button not working in excel 2010
    By cneha1991 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 11-30-2011, 07:36 AM
  2. Command button code not working
    By mariposa in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-06-2011, 05:03 AM
  3. Command button is not working by using VBA
    By Webtekr in forum Outlook Programming / VBA / Macros
    Replies: 1
    Last Post: 03-28-2009, 02:22 AM
  4. Command button not working properly on different sheet
    By Strikez in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-07-2007, 12:36 AM
  5. command button isn't working
    By Nydia in forum Excel - New Users/Basics
    Replies: 1
    Last Post: 04-29-2005, 06:06 PM

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