求助excel宏代码

2025-04-02 22:32:14
推荐回答(4个)
回答1:

假设第一个表叫“表1”,第二个表叫“表2”,如果表1的一个数据在表2中存在,且表2同行B列为1,则将表2同行B列变为0,同时清除表1中的这个数据,与上述描述不符的,则不清除表1数据。
代码如下:
Sub 查找()
Set sh1 = Sheets("表1")
Set sh2 = Sheets("表2")
For i = 1 To sh1.[a65536].End(xlUp).Row
n = 0
For j = 1 To sh2.[a65536].End(xlUp).Row
If sh1.Cells(i, 1) = sh2.Cells(j, 1) Then
If sh2.Cells(j, 2) = 1 Then sh2.Cells(j, 2) = 0: n = 1
End If
Next
If n = 1 Then sh1.Cells(i, 1) = ""
Next
End Sub

回答2:

lZ可以到excelhome论坛去发帖喔

回答3:

不明白意思,发详细内容。

回答4:

这个代码,不简单哦