我有一个 excel 表,如果三列有相同的数据删除第二个和第三个,我想删除。我可以写 4. 列数据相同或不同,但我不能先设置 1. 2. 或 3. 列数据
=IF((AND(A1=B1;B1=C1));"相同";"不同")
a b c
a b b
a a a
至
a b c
a b b
a
最佳答案
您可以将其放入新模块中,但宏将在 Active Sheet 上运行:
Sub DeleteCells()
Dim intResponse, i As Integer
i = 1
intResponse = MsgBox("Are you sure you want " & _
"to delete the cells?", vbYesNo)
If intResponse = vbYes Then
Do While Cells(i, 1).Value <> "" 'does it one by one going down in the first column while the cell is not empty
If (Cells(i, 1) = Cells(i, 2)) And (Cells(i, 1) = Cells(i, 3)) Then
Cells(i, 2).Value = ""
Cells(i, 3).Value = ""
End If
i = i + 1
Loop
End If
End Sub
关于excel - Excel中删除单元格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52852378/