gpt4 book ai didi

excel - Excel中删除单元格

转载 作者:行者123 更新时间:2023-12-04 22:30:59 25 4
gpt4 key购买 nike

我有一个 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com