我想创建一个VBA代码,用于根据其包含的选项卡数删除单元格内容。例如:在K列中,删除单元格内容(如果它包含5个选项卡,低于101-6或101-将被删除但101-61不会被删除。
提前致谢!
答案 0 :(得分:0)
Dim myLastRow As Long
Dim i As Long
Application.ScreenUpdating = False
' Find last row
myLastRow = Cells(Rows.Count, "J").End(xlUp).Row
' Loop through range
For i = 6 To myLastRow
If mid(Cells(i, "J").Value ,instr(Cells(i, "J").Value ,"-"),) <=5 Then Range(Cells(i, "O"), Cells(i, "Y")).ClearContents
Next i
Application.ScreenUpdating = True