View Single Post
  #12   Report Post  
Posted to microsoft.public.excel.programming
Joergen Bondesen Joergen Bondesen is offline
external usenet poster
 
Posts: 110
Default Name Sheets in Series

Hi Don

I am not able to run your macro.
I think this line ms = Right(ws.Name, Len(ws.Name) - 1 - 1)
must be changed to ms = Right(ws.Name, Len(ws.Name) - i + 1)
I do hope you agree with me.

--
Best regards
Joergen Bondesen


"Don Guillett" wrote in message
...
typo due to testing
If UCase(Left(ws.Name, 2)) = "DATABASE" Then

If UCase(Left(ws.Name, 8)) = "DATABASE" Then


--
Don Guillett
SalesAid Software

"Don Guillett" wrote in message
...
One way to try

Sub addsheet()
For Each ws In Worksheets
If UCase(Left(ws.Name, 2)) = "DATABASE" Then
For i = 1 To Len(ws.Name)
If Mid(ws.Name, i, 1) Like "*[0-9]*" Then _
Exit For
Next i
ms = Right(ws.Name, Len(ws.Name) - 1 - 1)
If ms mn Then mn = ms
End If
Next ws
Sheets.Add
ActiveSheet.Name = "Database" & mn + 1
End Sub

--
Don Guillett
SalesAid Software

"Jac" wrote in message
...
hi,

I have created a MS Excel macro that can help me to insert a new sheet
and
named it as Database but this macro will delete the Database sheet if I
run
it again.

So, I would like to create a MS Excel macro which could help me to name
each
sheet in series. For example, if previously there is a sheet already
named as
Database1, then the next time, I run the macro it should name the newly
inserted sheet as Database2.

Could anyone help? cause I have no ideal how to compare the names of
sheets
in a workbook.

Thanking in advance