Hi
I want to insert many new worksheets in a workbook (near about 100). Problem is naming each sheet manually. I need a macro which can do this for me by assigning different names to newly inserted worksheets from a given list.
Regards
Zaigham
Printable View
Hi
I want to insert many new worksheets in a workbook (near about 100). Problem is naming each sheet manually. I need a macro which can do this for me by assigning different names to newly inserted worksheets from a given list.
Regards
Zaigham
Hi
Code:Option Explicit
Sub kTest()
Dim NameList, i As Long, msg As String
Application.ScreenUpdating = False
With ThisWorkbook
NameList = .Worksheets("Sheet1").Range("a2:a100") 'adjust this list
On Error Resume Next
For i = 1 To UBound(NameList, 1)
If Len(NameList(i, 1)) Then
.Worksheets.Add().Name = NameList(i, 1)
If Not Err.Number = 0 Then
msg = msg & vbLf & NameList(i, 1)
Err.Clear
End If
End If
Next
End With
If Len(msg) Then
MsgBox "The following names are not valid to rename the sheets." & vbLf & msg, vbInformation
End If
Application.ScreenUpdating = True
End Sub
Hi Admin
It works fine. Just inserts sheets in descending order and it is not a big problem. I am really thankful to you.:)
Now it works very fine. Thank you very much.%D