+ Reply to Thread
Results 1 to 4 of 4

Using VBA to delete a button with a row

Hybrid View

SV_Ryder Using VBA to delete a button... 08-28-2009, 06:15 PM
Andy Pope Re: Using VBA to delete a... 08-29-2009, 10:13 AM
SV_Ryder Re: Using VBA to delete a... 08-31-2009, 10:58 AM
Andy Pope Re: Using VBA to delete a... 08-31-2009, 11:12 AM
  1. #1
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,482

    Re: Using VBA to delete a button with a row

    You would need to loop through all the buttons and check there TopLeftCell property. If it matches the current row the delete the control
    Cheers
    Andy
    www.andypope.info

  2. #2
    Registered User
    Join Date
    08-27-2009
    Location
    Sacramento, CA
    MS-Off Ver
    Excel 2003
    Posts
    2

    Re: Using VBA to delete a button with a row

    I use the TopLeftCell property to select the cell under the button, but that is as much as I know. Can I get an example of how to use it in the loop as discribed and then delete the control?

    Thank you

  3. #3
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,482

    Re: Using VBA to delete a button with a row

    Assumes the buttons are assigned to PressMe macro

    Sub PressMe()
    
        Dim shpTemp As Shape
        Dim lngRow As Long
        Dim lngIndex As Long
        
        lngRow = ActiveSheet.Shapes(Application.Caller).TopLeftCell.Row
        For lngIndex = ActiveSheet.Shapes.Count To 1 Step -1
            If ActiveSheet.Shapes(lngIndex).TopLeftCell.Row = lngRow Then
                ActiveSheet.Shapes(lngIndex).Delete
            End If
        Next
        ActiveSheet.Rows(lngRow).Delete
        
    End Sub

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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