ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How do I delete entirerow that contains few command buttons (https://www.excelbanter.com/excel-programming/317558-how-do-i-delete-entirerow-contains-few-command-buttons.html)

John[_91_]

How do I delete entirerow that contains few command buttons
 
Hi all,

How can I have a command button that execute to delete entirerow, which few
other command buttons are contains inside this row. If I do
EntireRow.Select , it won't select the button objects which are on top of
this row. Pls help.

Many Thanks

John



Dick Kusleika[_4_]

How do I delete entirerow that contains few command buttons
 
John

Those buttons live on a layer that is different than the cell grid. If you
want to delete row 10, for instance, you could delete all the buttons on
that row, then delete the row.

Sub DelRowAndButtons()

Dim cb As Button

With Sheet1.Range("A10").EntireRow
For Each cb In Sheet1.Buttons
If Not Intersect(cb.TopLeftCell, .Cells) Is Nothing Then
cb.Delete
End If
Next cb
.Delete
End With

End Sub

This loops through all the buttons on the sheet. If the TopLeftCell (which
is a Range object) is in the Row 10, it is deleted. Then Row 10 is deleted.

--
Dick Kusleika
MVP - Excel
Excel Blog - Daily Dose of Excel
www.dicks-blog.com


"John" wrote in message
...
Hi all,

How can I have a command button that execute to delete entirerow, which
few
other command buttons are contains inside this row. If I do
EntireRow.Select , it won't select the button objects which are on top of
this row. Pls help.

Many Thanks

John






All times are GMT +1. The time now is 06:14 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com