答案1
创建一个模块并插入代码。比较 Sheet2 的单元格D3
和E3
的值;如果它们相等并且不为空,则A2:A3000
清除 Sheet1 范围内的值。
Sub ClearRange()
Dim wb As Workbook
Dim ws1, ws2 As Worksheet
Set wb = ThisWorkbook
Set ws2 = wb.Sheets("Sheet2")
'Check if the cells have the same value and if they are not empty
If (ws2.Range("D3").Value = ws2.Range("E3").Value) _
And ws2.Range("D3").Value <> "" _
And ws2.Range("E3").Value <> "" Then
Set ws1 = wb.Sheets("Sheet1")
'Clear the range
ws1.Range("A2:A3000").Clear
End If
End Sub