Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Sheet Name as a Variable?


Hiya experts!!

I have recorded!!!! (shame? naaah I have no shame!! :) )
macro that inserts new spreadsheets into the workbook and it just fail
to deliver because of the set name e.g. "Sheet2".

Could you please let me know how to make this new sheet a variable an
then via a msgBox enable the user to rename it? I guess it would b
something like that:

Sheets("VARIABLE").Name = "msgBox INPUT"

Many thanks!

--
Petitboeu
-----------------------------------------------------------------------
Petitboeuf's Profile: http://www.excelforum.com/member.php...fo&userid=1060
View this thread: http://www.excelforum.com/showthread.php?threadid=49517

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 703
Default Sheet Name as a Variable?

Dim SheetName As String
SheetName = InputBox("Enter Sheet Name")
If SheetName < "" Then CreateSheet SheetName
....

Public Sub CreateSheet(SheetName As String)
'
' if the sheet already exists select it
'
On Error GoTo CreateNewSheet
Sheets(SheetName).Select
Exit Sub
'
' if not create it
'
CreateNewSheet:
Sheets.Add After:=Sheets(Sheets.Count)
Sheets(Sheets.Count).Name = SheetName
'
End Sub



"Petitboeuf" wrote:


Hiya experts!!

I have recorded!!!! (shame? naaah I have no shame!! :) ) a
macro that inserts new spreadsheets into the workbook and it just fails
to deliver because of the set name e.g. "Sheet2".

Could you please let me know how to make this new sheet a variable and
then via a msgBox enable the user to rename it? I guess it would be
something like that:

Sheets("VARIABLE").Name = "msgBox INPUT"

Many thanks!!


--
Petitboeuf
------------------------------------------------------------------------
Petitboeuf's Profile: http://www.excelforum.com/member.php...o&userid=10602
View this thread: http://www.excelforum.com/showthread...hreadid=495170


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Sheet Name as a Variable?


thanks a lot! works a treat! :)

I didn't think this would cause a problem but... I don't seem to b
able to 'Select All' on my XL spreadsheet.
It either does a Cells.Select for then Copy but fails when hittin
it...

Any ideas? :cool

--
Petitboeu
-----------------------------------------------------------------------
Petitboeuf's Profile: http://www.excelforum.com/member.php...fo&userid=1060
View this thread: http://www.excelforum.com/showthread.php?threadid=49517

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
Add sheet name into a variable. Richhall[_2_] Excel Worksheet Functions 1 September 18th 09 12:11 PM
variable sheet name Gisela Excel Discussion (Misc queries) 6 September 14th 09 01:25 PM
How To make a sheet reference Variable (eq: sum(sheet!D2:H2)) John Linker Excel Discussion (Misc queries) 3 June 16th 08 11:29 PM
Variable sheet and Formula Sheet Emmett423 Excel Discussion (Misc queries) 2 March 31st 06 02:14 AM
variable in a link where the variable is the name of the sheet darrelly Excel Worksheet Functions 1 October 7th 05 08:24 AM


All times are GMT +1. The time now is 09:49 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"