LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 40
Default Rename the sheet just added

Hi,

I want to be able to programmatically insert a new worksheet and then rename
this newly added sheet to the contents of an input box.
How can I reference the newly added worksheet from code?

eg
dim sName as string
Sheets.Add
sName = inputbox("Enter sheet name")
Sheets("Sheet4").Select
Sheets("Sheet4").Name = sName

The only problem with this code, I think, is that the newly created
worksheet will not always be called "Sheet4" as it will always increment by
1. Is there a way to count the no. of worksheets in a workbook so that I
can have a variable in the code instead of "Sheet4"

Thanks


 
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 rename a sheet if the rename tab is inactive? Nelson Excel Worksheet Functions 1 March 3rd 10 10:28 AM
macro to: Add new sheet, then rename new sheet with todays date Paul Excel Worksheet Functions 3 September 29th 07 03:17 AM
Move data to new sheet - rename sheet based on criteria ? [email protected] Excel Discussion (Misc queries) 7 May 16th 07 10:22 PM
Rename Sheet Linda@VZ Excel Discussion (Misc queries) 1 November 2nd 05 12:43 PM
how do I rename a sheet jonwyn New Users to Excel 2 March 1st 05 08:36 PM


All times are GMT +1. The time now is 08:39 AM.

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"