sub delete_without_asking()
Application.DisplayAlerts = False 'this stops from asking for each sheet!!!
Application.ScreenUpdating = False
my_array = Array("Nike", "Adidas")
For Each blatt In ActiveWorkbook.Sheets
test_value = blatt.Name
Z = in_array(my_array, test_value)
If Z = False Then
blatt.Delete
End If
Next blatt
Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub
my_array = Array("Nike", "Adidas")
For Each sh In ActiveWorkbook.Sheets
If UBound(Filter(my_array, sh.Name, True, vbTextCompare)) < 0 Then sh.Delete
Next sh
2条答案
按热度按时间dgsult0t1#
ergxz8rk2#
还有其他方法可以检查数组,而不需要遍历数组: