Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
Mike
 
Posts: n/a
Default Insert A Worksheet using VBA

I have a workbook that I need to add a Worksheet called "CurWorkPad" to.

Right now I can insert a worksheet and it will come up named "Sheetx", where
x=a number that increments each time a sheet is inserted. I also have code
to rename a worksheet, but it requires you to know the current name of the
inserted worksheet.

Is there a way to insert a new worksheet and rename it at the same time
without knowing what excel named the new worksheet?

Thanks for any help.
Mike

  #2   Report Post  
Posted to microsoft.public.excel.misc
Sloth
 
Posts: n/a
Default Insert A Worksheet using VBA

when you insert the worksheet the new worksheet becomes selected
automatically, so you can use this to rename the new sheet

ActiveSheet.Name = "New_Name"

"Mike" wrote:

I have a workbook that I need to add a Worksheet called "CurWorkPad" to.

Right now I can insert a worksheet and it will come up named "Sheetx", where
x=a number that increments each time a sheet is inserted. I also have code
to rename a worksheet, but it requires you to know the current name of the
inserted worksheet.

Is there a way to insert a new worksheet and rename it at the same time
without knowing what excel named the new worksheet?

Thanks for any help.
Mike

  #3   Report Post  
Posted to microsoft.public.excel.misc
flow23
 
Posts: n/a
Default Insert A Worksheet using VBA

Try this

Sub addsheet()
Sheets.Add.Name = "CurWorkPad"
End Sub

change " curworkpad" to any name you want



"Mike" wrote:

I have a workbook that I need to add a Worksheet called "CurWorkPad" to.

Right now I can insert a worksheet and it will come up named "Sheetx", where
x=a number that increments each time a sheet is inserted. I also have code
to rename a worksheet, but it requires you to know the current name of the
inserted worksheet.

Is there a way to insert a new worksheet and rename it at the same time
without knowing what excel named the new worksheet?

Thanks for any help.
Mike

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I insert a new worksheet consecutively? lady-pearl Excel Discussion (Misc queries) 6 December 20th 05 04:47 PM
How do I insert just one worksheet of a workbook into an email? Sarah Excel Discussion (Misc queries) 2 December 19th 05 08:17 PM
Protect Worksheet but allow to insert or delete rows Bob L Hilliard Excel Discussion (Misc queries) 2 June 9th 05 02:08 PM
Insert comment in protected worksheet The Tuner Excel Worksheet Functions 2 June 6th 05 11:38 PM
Insert worksheet ParTeeGolfer Excel Worksheet Functions 1 January 10th 05 07:03 PM


All times are GMT +1. The time now is 01:32 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"