excel - Excel中删除单元格

标签 excel excel-2010

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

相关文章:

excel - 在一个逗号分隔的单元格中显示所有匹配的值

excel - 查找团队中第二大的分数并返回名称

Excel 精确单词匹配

ruby - 使用 roo gem 在 ruby​​ 中写入 excel 文件

regex - 有没有一种简单的方法可以在Excel中替换占位符?

excel - 如何在 VBA (Excel 2010) 中将默认情况恢复为变量?

excel-formula - Excel中两个日期时间之间的总小时数的公式

excel-2010 - Excel 2010中,如何使用键盘快捷键过滤下拉列表复选框?

Excel 打印带有正确小数分隔符的数字

javascript - 在 Office 应用程序的 Excel.run 中重用范围对象