+ Reply to Thread
Results 1 to 2 of 2

[SOLVED] Removing button(s) in macro (not working under specific circumstance)

  1. #1
    Registered User
    Join Date
    01-07-2010
    Location
    Indiana, USA
    MS-Off Ver
    Excel 2007
    Posts
    24

    [SOLVED] Removing button(s) in macro (not working under specific circumstance)

    This is driving me crazy and I cannot seem to figure it out. There is a button for the macro on each sheet in the workbook so that you can run it no matter what sheet you are on (so you can select the sheets you want to keep and always have access to the macro). The macro basically converts all formulas to values, determines how many pages are needed and adds a line at the bottom of the last page for that worksheet. It should then go through and delete the sheets that are not selected, and the sheets that are selected it should delete columns with information just used for formulas before it converted them to values. It then should remove the button that is on the selected sheets and then save the file and delete the macros/visual basic coding.

    The issue is coming with removing the buttons from the sheets that are selected. The coding works on each sheet individually (including "Sheet1"), and will work on groups of sheets as long as "Sheet1" is not a selected sheet in the group. As soon as you select "Sheet1" with other sheets I get the error:

    Run-time error '1004':
    Application-defined or object-defined error

    What could be causing this error since it works on "Sheet1" by itself, but then when part of a group it seems to be failing because of "Sheet1"?

    I included all coding in case it was being caused by coding in another part, but the coding works just as it should if I just leave the buttons there, so willing to receive input on anything else you see "wrong", but would like the main problem solved.

    The line it is stopping on is bold in the code.

    Please Login or Register  to view this content.
    Last edited by ben98gs; 11-22-2011 at 04:17 PM. Reason: Solved.

  2. #2
    Registered User
    Join Date
    01-07-2010
    Location
    Indiana, USA
    MS-Off Ver
    Excel 2007
    Posts
    24

    Re: Removing button(s) in macro (not working under specific circumstance)

    Well, I fixed it... I was trying different things before I posted this including "ws.activate" before that command line. Had a co-worker look at it (without showing him what I had been trying) and he had the same thought to try and fix it that I did, but he used "ws.select" and that seems to work.

+ 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