auto insert and name new sheet

L

laneman

I want to tell a macro to create a new sheet and name it. The shee
names are serial numbers in sequence. So if the active sheet is name
1045, I want the macro to insert a new sheet and call it 1046. If thi
is possible, I would also like the macro to update the heading of th
new sheet to show the new serial number as well
 
V

Vasant Nanavati

Something like:

Dim ws As Worksheet
On Error Resume Next
Set ws = Worksheets.Add(After:=Worksheets(Worksheets.Count))
ws.Name = CStr(CInt(Worksheets(Worksheets.Count - 1).Name) + 1)
ws.Range("A1") = ws.Name
On Error GoTo 0
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top