从另一个Excel工作表中删除匹配数值的行。

huangapple go评论69阅读模式
英文:

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
从另一个Excel工作表中删除匹配数值的行。从另一个Excel工作表中删除匹配数值的行。从另一个Excel工作表中删除匹配数值的行。

答案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(&quot;Sheet1&quot;).Rows(numRows).Delete
    Sheets(&quot;Sheet2&quot;).Rows(numRows).Delete
End Sub

<!-- end snippet -->

huangapple
  • 本文由 发表于 2023年5月14日 21:49:53
  • 转载请务必保留本文链接:https://go.coder-hub.com/76247817.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定