作者:手机用户2502899267 | 来源:互联网 | 2023-06-15 11:24
Iwouldlikeamacro,thatrunswhenacellwiththetextvalueDELETEisclicked,anddeletesent
I would like a macro, that runs when a cell with the text value "DELETE" is clicked, and deletes entire the range of rows from one cell above and 19 cells below the cell with the value "DELETE".
我想要一个宏,它在单击文本值为“DELETE”的单元格时运行,并从单元格下方的单元格和“DELETE”下面的19个单元格中删除整个行范围。
For example if cell X7 has the value "DELETE", when it is clicked rows 6:26 are deleted.
例如,如果单元格X7的值为“DELETE”,则单击它时将删除行6:26。
The code I have so far is:
我到目前为止的代码是:
Private Sub Delete_Type(ByVal Target As Excel.Range)
If Target.Address = "$X$7" Then
Rows("(Row(), Column(),1, 4):((Row(), Column(), 4)+19)").Select
Selection.delete Shift:=xlUp
End If
End Sub
1 个解决方案