在Sheet1
A3
中有一个号码(并非总是相同)
在Sheet2
中,我想删除整列,其中A列包含与Sheet1!A3
相同的值(蓝色):
使用不同的数字:
和以前一样,我们删除了行:
......等等。
这是我的代码,但什么都没发生;没有错误,但没有删除任何行。
Dim rng As Range
Dim WB As Workbook
Dim i As Integer
Application.ScreenUpdating = False
Set WB = ActiveWorkbook
Set rng = WB.Sheets("Données Enregistrées").Range("B:B").Find(What:=WB.Sheets("Modification").Range("A3"), _
LookIn:=xlValues, LookAt:=xlWhole, MatchCase:=False)
While Not rng Is Nothing
rng.Rows("Modification").EntireRow.Delete
Set rng = WB.Sheets("Données Enregistrées").Range("B:B").Find(What:=WB.Sheets("Modification").Range("A3"), _
LookIn:=xlValues, LookAt:=xlWhole, MatchCase:=False)
Wend
Application.ScreenUpdating = True
答案 0 :(得分:-1)
好的,这个代码将为你完成这项工作我至少在删除部分,但你必须适应你的其余代码
你不清楚它发生了多少时间,所以只要你需要建立一个循环
Dim f As String
f = Worksheets(1).Range("A3")
'Since i didn't got that clear, here above you must create
'a code to declare "f" as whatever you want the code will than
'search that f value on the "A" column of Sheets(2) and delete
'the first that contains that value, build a loop if it happens
'more than once
Set c = Worksheets(2).Range("A:A").Find(f)
Range(c.address()).EntireRow.Delete