If you care about the order of the sheets (alpha ascending), try
either of the following. AAA puts the sheet directly in the
appropriate position. BBB always adds to the end and then sorts in
alpha ascending order.
Sub AAA()
Dim R As Range
Dim WS As Worksheet
Dim N As Long: N = 1
On Error Resume Next
For Each R In Worksheets("SHeet1").Range("A1:A10")
If Len(R.Text) > 0 Then
Err.Clear
Set WS = Nothing
Debug.Print R.Text, N
Set WS = ThisWorkbook.Worksheets(R.Text)
If Err.Number = 0 Then
N = WS.Index
Else
With ThisWorkbook.Worksheets
.Add(after:=.Item(N)).Name = R.Text
N = N + 1
End With
End If
End If
Next R
End Sub
Sub BBB()
Dim R As Range
Dim N As Long
Dim M As Long
Dim WS As Worksheet
On Error Resume Next
For Each R In Worksheets("Sheet1").Range("A1:A10")
If R.Text <> vbNullString Then
Err.Clear
Set WS = Nothing
Set WS = Worksheets(R.Text)
If Err.Number = 9 Then
ThisWorkbook.Worksheets.Add.Name = R.Text
End If
End If
Next R
' sort sheets
With Worksheets
For N = 1 To .Count
For M = N + 1 To .Count
If StrComp(.Item(M).Name, .Item(N).Name, vbTextCompare) >
0 Then
.Item(M).Move after:=.Item(N)
End If
Next M
Next N
End With
End Sub
Cordially,
Chip Pearson
Microsoft Most Valuable Professional,
Excel, 1998 - 2010
Pearson Software Consulting, LLC
www.cpearson.com