View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.misc
Gord Dibben Gord Dibben is offline
external usenet poster
 
Posts: 22,906
Default how to change the sheet name by the cell value?

Insert one sheet or multiples based on a list?

Play with these........adjust to suit.

Sub Add_Sheets()
Dim rCell As Range
For Each rCell In Sheets("Sheet1").Range("A1:A5")
With Worksheets.Add(After:=Worksheets(Worksheets.Count) )
.Name = rCell.Value
End With
Next rCell
End Sub


Sub Add_One_Sheet()
Dim rCell As Range
Sheets("Sheet1").Select
Set rCell = Application.InputBox(prompt:= _
"Select A Cell", Type:=8)
With Worksheets.Add(After:=Worksheets(Worksheets.Count) )
.Name = rCell.Value
End With
End Sub


Gord Dibben MS Excel MVP

On Sat, 7 Jun 2008 08:29:01 -0700, Kim wrote:

Hi,

I've created a macro to insert a new sheet but I have a list of name in a
sheet. Can I code vba to change the new sheet name as my list.
Suppose in cell A1, its value is Cat. (In sheet1).
When I insert a new sheet. I want to change the sheet name as Cat
automatically.

How can I do that?
Thank you.