英文:
Delete row with Match value from other worksheet Excel
问题
我想编写一些代码,当我在Sheet1中选择一个单元格然后按下删除键时,它将从Sheet1中删除整个所选行(例如:第8行),然后对Data sheet上的确切值执行相同的操作(我想使用PT-2在数据表上找到确切的行),但我不知道如何做。
英文:
I want to write some code that when I choose a cell then press Delete on sheet1 it will delete the entire selected row from sheet1 (ex: row 8) and do the same thing for the exact value on the Data sheet ( I want to use the PT-2 to find the exact row on the data sheet ) but I don't know how
答案1
得分: 1
这允许您每次运行宏时从“Sheet1”和“Sheet2”中删除行。
Sub DeleteSelectedRow()
Dim numRows As Long
Dim i As Long
numRows = ActiveCell.Row
Sheets("Sheet1").Rows(numRows).Delete
Sheets("Sheet2").Rows(numRows).Delete
End Sub
英文:
This allows you to delete the row from both "Sheet1" and "Sheet2" each time you run the macro.
<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: lang-html -->
Sub DeleteSelectedRow()
Dim numRows As Long
Dim i As Long
numRows = ActiveCell.Row
Sheets("Sheet1").Rows(numRows).Delete
Sheets("Sheet2").Rows(numRows).Delete
End Sub
<!-- end snippet -->
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论