Hi Murtaza,
Please try to ask the entire question in the initial question.
Oh and don't put URGENT on the subject title, everybody's question
is important to them. Some people will avoid such questions, while
others may purposely select them first, it really won't improve the
quality or the speed in getting an answer.
It is disconcerting to be told that what I wrote does not work,
not having seen the other question you asked in this thread in reply to
someone else. when in fact you are asking an additional question
to each person that answers.
This is not a very popular newsgroup it was dropped for several
years by Microsoft. Essentially excel.misc would be the
group for general questions, and excel.worksheet.functions
for builtin worksheet functions, but since yours is a programming
question and you know how to install and use a macro the
newsgroup for future questions (new threads) concerning VBA
questions in Excel would be excel.programming
Sub GenWStabnames2()
'David McRitchie based on previous code in sheets.htm
Dim cell As Range
Dim newName As String, xx As String
Err.Description = ""
On Error Resume Next
'--cells with numbers, including dates, will be ignored,
For Each cell In Intersect(Selection, _
Selection.SpecialCells(xlConstants, xlTextValues))
'Sheets.Add after:=Sheets(Sheets.Count)
Worksheets("MyBeginning").Copy after:=Worksheets(Worksheets.Count)
If Err.Description <> "" Then Exit Sub
Err.Description = ""
newName = cell.Text
ActiveSheet.Name = newName
If Err.Description <> "" Then
'--failed to rename, probably sheetname already exists...
xx = MsgBox("Failed to rename inserted worksheet " & _
vbLf & _
ActiveSheet.Name & " to " & newName & vbLf & _
Err.number & " " & Err.Description, vbOKCancel, _
"Failed to Rename Worksheet, it will be deleted:")
'--eliminate already created sheet that failed to be renamed...
Application.DisplayAlerts = False
ActiveSheet.Delete
Application.DisplayAlerts = True
'--check for immediate cancellation...
If xx = vbCancel Then Exit Sub
Err.Description = ""
End If
Next cell
End Sub
--
Murtaza said:
Hi David
thanks for your efforts, your macro create default blank sheets, but i want
to create sheet based on my sample sheet. I have tried XLStart folder
options but it not work.
any comments?
Regards,
Murtaza
---original question---