Results 1 to 2 of 2

Delete command button

Threaded View

  1. #1
    Forum Contributor KBSH's Avatar
    Join Date
    09-16-2015
    Location
    Netherlands
    MS-Off Ver
    2013
    Posts
    113

    Question Delete command button

    Hey

    I'm trying to make a command button that removes itself from the sheet after it's been pushed.
    I've tried the following code, but can't seem to make it work.
    Sub deleteshapesinrange()
    
    Dim rng As Range
    ActiveSheet.Shapes(Application.Caller).TopLeftCell.Offset(1, 1).Activate
    Set rng = Range(ActiveCell, ActiveCell)
    
    Dim shp As Shape
    
    For Each shp In ActiveSheet.Shapes
        If Not Intersect(shp.TopLeftCell, rng) Is Nothing Then shp.Delete
    Next shp
    End Sub
    The code above selects the cell to the bottem right of the command button and I'm not experienced enough to fix the problem.
    The real problem actually is that the range needs to be dynamic.
    It would be nice if anyone could help me.
    Last edited by KBSH; 02-23-2016 at 07:34 AM.
    I'm mediocre with VBA, but getting there

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. VBA code to create command button. Print all sheets then delete command button.
    By Declamatory in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 11-15-2015, 05:18 PM
  2. [SOLVED] How to delete a row using a command button
    By AndyMan81 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 08-01-2014, 10:20 AM
  3. [SOLVED] Delete a VBA Command Button after run?
    By NicksDad in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-18-2013, 10:27 AM
  4. [SOLVED] Can't delete Command Button on Worksheet
    By eemiller1997 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-07-2013, 02:20 PM
  5. [SOLVED] Delete command button ?
    By SpookiePower in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-23-2006, 10:55 AM
  6. Delete a command button via VBA
    By Brian K. Sheperd in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-08-2005, 11:05 AM
  7. Delete with command button?
    By John in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-17-2005, 10:06 AM

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