Delete Row Button VBA

dannyok90

Board Regular
Joined
Aug 30, 2016
Messages
115
Hi All,

Racking my brain a little.. got some code below that deletes a row using a button..
the delete row button is at the begining of the row in column a. The code deletes the row fine
but not the button? the button just goes really small.. how could i get the command to delete the
entire row and any buttons in it?
Thanks,
Dan


Code:
Option Explicit
Sub deletebutton()
    Dim rng As Range
    Dim rngOld As Range
    Dim msgRes As VbMsgBoxResult
    

    Set rngOld = ActiveCell
    Set rng = ActiveSheet.Shapes(Application.Caller).TopLeftCell.EntireRow

    rng.Select
    msgRes = MsgBox("Proceed?", vbOKCancel, "About to Delete this row.")
    If msgRes = vbOK Then
    Sheet1.Unprotect Password:="xyz"
        rng.Delete
    Sheet1.Protect Password:="xyz"
    End If
    rngOld.Select
End Sub
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
Try inserting this line above rng.Delete
Code:
ActiveSheet.Shapes(Application.Caller).Delete
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,593
Messages
6,120,434
Members
448,961
Latest member
nzskater

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top