How to Determine Range of A Generic Button Call, Then Delete The Row

emp1346

New Member
Joined
Nov 15, 2013
Messages
2
So I have a spreadsheet driven by some data-entry cells and macros, whereby information from the input forms is added to a table... As part of this process, I want to create a standard button (form control) that can later be clicked to delete the associated row (i.e. the table entry)...

Here's where I'm at, and I haven't been able to figure out what's wrong with it:

Dim ButtonObject As Object
Dim cs, rs As Integer
Set ButtonObject = ActiveSheet.Buttons(Application.Caller)
With ButtonObject.TopLeftCell
rs = .Row
cs = .Column
End With
Range(Cells(rs, cs)).EntireRow.Delete

The debugger keeps stopping on the last line, but I don't know why...

EDIT - FIGURED IT OUT, NEVERMIND
Turns out I was trying too hard... The following worked just fine:

Dim ButtonObject As Object
Set ButtonObject = ActiveSheet.Buttons(Application.Caller)
ButtonObject.TopLeftCell.EntireRow.Delete
 
Last edited:

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.

Forum statistics

Threads
1,214,897
Messages
6,122,141
Members
449,066
Latest member
Andyg666

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