+ Reply to Thread
Results 1 to 6 of 6

Deleting objects using Macro

Hybrid View

dreicer_Jarr Deleting objects using Macro 04-15-2008, 01:52 PM
NBVC Please read the forum... 04-15-2008, 01:54 PM
Portuga I think you just needed to... 04-15-2008, 02:01 PM
dreicer_Jarr Deleting objects Macro 04-15-2008, 02:14 PM
Portuga I tested the code in my... 04-15-2008, 02:17 PM
NBVC dreicer_Jarr, I see you... 04-15-2008, 02:55 PM
  1. #1
    Forum Contributor
    Join Date
    04-02-2008
    Location
    Jacksonville Beach, Florida
    MS-Off Ver
    Microsoft Excel 2003 and 2010
    Posts
    264

    Deleting objects using Macro

    I have always used a script like this (see below) to delete all objects on my workbook page. However, I have always had the problem that when a user other than myself runs this macro twice, it shifts/deletes a row and messes up the entire workbook. I just need a macro that does the same thing (deletes all objects on a sheet), but one that a user could click multiple times and not mess anything up.

      Worksheets("dept council").Select
        Range("A1").Select
        Worksheets("dept council").Shapes.SelectAll
        Selection.DELETE
        Range("A1").Select
        Worksheets("control panel").Select
        Range("A1").Select
    Last edited by NBVC; 04-15-2008 at 02:53 PM.

  2. #2
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898
    Please read the forum guidelines.

    Please Update your title to something more relevant to the question at hand.

    Please use Code tags to display your sample code.
    Where there is a will there are many ways.

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below left corner

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

  3. #3
    Forum Contributor Portuga's Avatar
    Join Date
    02-20-2004
    Location
    Portugal
    MS-Off Ver
    365
    Posts
    852
    I think you just needed to clean up the code a bit.

    Worksheets("dept council").Select
    Worksheets("dept council").Shapes.SelectAll
    Selection.DELETE
    Worksheets("control panel").Select
    Last edited by Portuga; 04-15-2008 at 02:09 PM.
    If you found the solution to your question. Mark the thread as "Solved"
    Thank everyone that helped you with a valid solution by clicking on their

    There is no such thing as a problem, only a temporary lack of a solution

  4. #4
    Forum Contributor
    Join Date
    04-02-2008
    Location
    Jacksonville Beach, Florida
    MS-Off Ver
    Microsoft Excel 2003 and 2010
    Posts
    264

    Deleting objects Macro

    That's not it. I get an error about memory (run time error '7')...do you think it could have something to do with two other large macros in the workbook? Other thoughts?


    Sub DELETE()
    '
    ' DELETE Macro
    ' Macro recorded 3/18/2008 by Baptist User
    
        Worksheets("dept council").Select
        Worksheets("dept council").Shapes.SelectAll
        Selection.DELETE
        
        
        End Sub
    Last edited by NBVC; 04-15-2008 at 02:53 PM.

  5. #5
    Forum Contributor Portuga's Avatar
    Join Date
    02-20-2004
    Location
    Portugal
    MS-Off Ver
    365
    Posts
    852
    I tested the code in my machine and it works fine.

    It deletes every autoshape in the sheet and nothing else.
    If I click it again, the macro does nothing.

    Sub DELETE()
    
    Worksheets("dept council").Select
    Worksheets("dept council").Shapes.SelectAll
    Selection.DELETE
    
    End Sub

    Note:
    You need to fix your thread description as a lot of work is involved in having a searcheable database of problems.
    Last edited by Portuga; 04-15-2008 at 02:22 PM.

  6. #6
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898
    dreicer_Jarr,

    I see you changed your title, but the code tags needed to be placed too.

    I did that for you this time and restored Portuga's responses...

    Please remember to use the code tags and name your thread appropriately next time. Thanks.

+ 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