我试图根据形状的位置删除一行。在屏幕快照中,B7中有一个蓝色形状,我想单击该形状,将其完全删除,并将其下方的数据向上移动1行。
一旦我可以在每行上复制形状和伴随的宏,以便用户可以删除他们想要的任何名称。
我做了一些搜索,然后从这段代码开始。
Sub Delete_Borrower()
'Macros ro delete individual borrowers fron dbase
Dim mysht As Worksheet
Dim myDropDown As Shape
Dim MLO As Range
Set mysht = ThisWorkbook.Worksheets("Borrower Database")
CallingShapeName = ActiveSheet.Shapes(Application.Caller).Name
Set MLO = Range(mysht.Shapes(CallingShapeName).TopLeftCell.Address)
MsgBox "OK" & MLO
'Code to delete row and shift rows below up one row
End Sub
答案 0 :(得分:0)
Sub NoSymbol1_Click()
Dim r As Range, shp As Shape
Set r = ActiveSheet.Shapes(Application.Caller).TopLeftCell 'find the range of the button clicked.
For Each shp In ActiveSheet.Shapes
If ActiveSheet.Shapes(Application.Caller).TopLeftCell = r.Address Then
shp.Delete
End If
Next shp
r.EntireRow.Delete
End Sub