Rename New Worksheet

March 5, 2009 by vba excel
Filed under: Excel Vba 
Sponsor

Excel Vba Question:

I kindly ask for help, ive a problem to rename new worksheet using excel vba function. In sheet1 i have a list, i need to create a new worksheet in a workbook and rename it with the value of cell which i selected in this list. I tried something like this, but it´s surely very simple

Sub Create()
Dim ws As Worksheet
Dim wsName As String
If Not IsEmpty(ActiveSheet.ActiveCell.Value) Then
Set ws = Worksheets.Add
ws.Move After:=Sheets(Sheets.Count)
ws.Name = ActiveSheet.ActiveCell.Text
End If
End Sub

Excel Vba Answer:

Small corrections of your excel vba function to rename new worksheet :

Sub Create()
Dim ws As Worksheet
Dim wsName As String
If Not IsEmpty(ActiveCell) Then
newname = ActiveCell.Value
Set ws = Worksheets.Add
ws.Move After:=Sheets(Sheets.Count)
ws.Name = newname
End If
End Sub

You have to do a small fix to the IsEmpty. You also need to capture the tab
name before the .Add
After the .Add the ActiveSheet becomes the new sheet, which is, of course,
a totally empty excel worksheet.

  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Google
  • E-mail this story to a friend!
  • Live
  • MisterWong
  • Propeller
  • StumbleUpon
  • Technorati
  • TwitThis
  • YahooMyWeb
  • Print this article!

Rate This Tips:

1 Star2 Stars3 Stars4 Stars5 Stars (2 votes, average: 4.00 out of 5)
Loading ... Loading ...


Incoming excel search terms

rename worksheet vba,excel vba rename worksheet,vba rename worksheet,vba rename sheet,rename sheet vba,adding and renaming worsheet,dynamically adding worksheet and renaming it,excel vba rename range,excel vba rename workbook,mss,rename sheets vba list,rename workbook vba,excel rename worksheet macro,excel rename worksheet vba,excel vba copy worksheet rename,excel vba create new worksheet,excel vba rename new sheet,f,hoe to rename worksheet in axcel,how to delete a worksheet that is not empty using vba?,macro for rename sheets from list,macro to copy and rename sheets,rename excel columns vba,rename excel sheet vba,rename excel worksheets using list,rename sheet tabs as dates excel,rename sheet with text,rename worksheet excel vba,rename worksheets vba,renaming worksheets in multiple workbooks vba,vba copy sheet,vba create new worksheet,vba rename tab,vba to rename sheet,adding worksheets using vba,access vba add new workshhet to workbook and rename sheet,access vba rename worksheet dim,add a new sheet at the beginning and rename it,add a sheet and rename excel macro,add a sheet and rename it in macro,add and rename a worksheet,add and rename worksheet vba,add multiple sheets and rename using vba,add new workbook using excel,add sheet & rename vba,add sheet and rename sheet in vba,add sheet using vba,add worksheet and rename,add worksheet and rename vba,add worksheet and rename with vba



Related Excel Tips

Comments

Have another excel answer or questions for this problem ?
Feel free to post it here..