Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Adding new sheet problem-Macro


I'm very new to this. I'm trying to open a new worksheet and call it a
name.
However, I never know what sheet name excel is going to give me:
sometimes "Sheet1" or "Sheet10". It depends on how many times I run
the macro.
Is there a way to convert this:
' Workbooks.Add
Sheets("Sheet1").Name = "M1"

to something more friendly?


--
pikapika13
------------------------------------------------------------------------
pikapika13's Profile: http://www.excelforum.com/member.php...o&userid=10892
View this thread: http://www.excelforum.com/showthread...hreadid=527159

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default Adding new sheet problem-Macro

one way:

With Worksheets.Add
On Error Resume Next 'in case M1 exists
.Name = "M1"
On Error GoTo 0
End With

In article ,
pikapika13
wrote:

I'm very new to this. I'm trying to open a new worksheet and call it a
name.
However, I never know what sheet name excel is going to give me:
sometimes "Sheet1" or "Sheet10". It depends on how many times I run
the macro.
Is there a way to convert this:
' Workbooks.Add
Sheets("Sheet1").Name = "M1"

to something more friendly?

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 336
Default Adding new sheet problem-Macro

When the sheet's first made, it's the active sheet so I'd change the second
line to:
ActiveSheet.Name = "M1"

"pikapika13" wrote:


I'm very new to this. I'm trying to open a new worksheet and call it a
name.
However, I never know what sheet name excel is going to give me:
sometimes "Sheet1" or "Sheet10". It depends on how many times I run
the macro.
Is there a way to convert this:
' Workbooks.Add
Sheets("Sheet1").Name = "M1"

to something more friendly?


--
pikapika13
------------------------------------------------------------------------
pikapika13's Profile: http://www.excelforum.com/member.php...o&userid=10892
View this thread: http://www.excelforum.com/showthread...hreadid=527159


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
VBA to stop XL from adding the Path Sring to Sheet-to-Sheet Links [email protected] Excel Discussion (Misc queries) 5 August 18th 06 01:46 PM
macro adding formula to new sheet toddsavage100 Excel Discussion (Misc queries) 2 March 14th 06 03:03 AM
problem macro to show a warning sheet... Pierre via OfficeKB.com[_2_] Excel Programming 4 November 2nd 05 01:18 AM
Problem with Macro/Protected Sheet johncassell[_26_] Excel Programming 2 August 23rd 05 01:43 PM
Macro and Protected Sheet Problem Daniel R. Young Excel Programming 4 July 21st 05 07:32 PM


All times are GMT +1. The time now is 10:07 AM.

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

About Us

"It's about Microsoft Excel"