我复制工作表,并从列表重命名。该列表包含非零值 - 这会产生问题。如何跳过空白单元格?
Sub AddSheet()
Application.ScreenUpdating = False
Worksheets("Sheet1").Activate
Dim bottomA As Integer
bottomA = Range("L" & Rows.Count).End(xlUp).Row
Dim c As Range
Dim ws As Worksheet
For Each c In Range("L5:L" & bottomA)
Set ws = Nothing
On Error Resume Next
Set ws = Worksheets(c.Value)
On Error GoTo 0
If ws Is Nothing Then
Sheets("LBO").Select
Sheets("LBO").Copy After:=Sheets(Sheets.Count)
ActiveSheet.Name = c.Value
End If
Next c
Application.ScreenUpdating = True
End Sub
非常感谢任何帮助。
答案 0 :(得分:0)
您应该在If
声明中添加其他条件。
例如,要避免存在空单元格:
If ws Is Nothing And Len(c) > 0 Then