Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default help with code please

Hi I have a macro which inserts a new worksheet at the end of the workbook
but the problem is when I click on cancel in the Inputbox it needs
debugging.

How can I change the code below to remove that particular worksheet when the
cancel button is pressed on the inputbox.

Worksheets.Add.Move after:=Worksheets(Worksheets.Count)
Dim NAMED As String
NAMED = InputBox("WHAT IS THE NAME OF THE WORKSHEET?")
ActiveSheet.Name = NAMED


Thanks

greg


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,646
Default help with code please

Worksheets.Add.Move after:=Worksheets(Worksheets.Count)
Dim NAMED As String
NAMED = InputBox("WHAT IS THE NAME OF THE WORKSHEET?")
If NAMED < "" Then
ActiveSheet.Name = NAMED
Else
' statements in case of Cancel
End If

Regards,
Stefi

€˛Greg€¯ ezt Ć*rta:

Hi I have a macro which inserts a new worksheet at the end of the workbook
but the problem is when I click on cancel in the Inputbox it needs
debugging.

How can I change the code below to remove that particular worksheet when the
cancel button is pressed on the inputbox.

Worksheets.Add.Move after:=Worksheets(Worksheets.Count)
Dim NAMED As String
NAMED = InputBox("WHAT IS THE NAME OF THE WORKSHEET?")
ActiveSheet.Name = NAMED


Thanks

greg



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default help with code please

Hi Greg

When you press cancel the input returns a empty string. You can't name a
sheet with a empty string. So you has to respond in a reasonable way to the
respond like: If name = "" then do something.

Ole

"Greg" wrote in message
...
Hi I have a macro which inserts a new worksheet at the end of the workbook
but the problem is when I click on cancel in the Inputbox it needs
debugging.

How can I change the code below to remove that particular worksheet when
the cancel button is pressed on the inputbox.

Worksheets.Add.Move after:=Worksheets(Worksheets.Count)
Dim NAMED As String
NAMED = InputBox("WHAT IS THE NAME OF THE WORKSHEET?")
ActiveSheet.Name = NAMED


Thanks

greg



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,124
Default help with code please

Sub WrongSheetName()
Sheets.Add After:=Sheets(Sheets.Count)
On Error GoTo wrongname
ActiveSheet.Name = InputBox("Sheet Name?")
Exit Sub
wrongname:
Application.DisplayAlerts = False
ActiveSheet.Delete
Application.DisplayAlerts = True
MsgBox "Name used Try again"
End Sub

--
Don Guillett
SalesAid Software

"Greg" wrote in message
...
Hi I have a macro which inserts a new worksheet at the end of the workbook
but the problem is when I click on cancel in the Inputbox it needs
debugging.

How can I change the code below to remove that particular worksheet when
the cancel button is pressed on the inputbox.

Worksheets.Add.Move after:=Worksheets(Worksheets.Count)
Dim NAMED As String
NAMED = InputBox("WHAT IS THE NAME OF THE WORKSHEET?")
ActiveSheet.Name = NAMED


Thanks

greg



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
split post code (zip code) out of cell that includes full address Concord Excel Discussion (Misc queries) 4 October 15th 09 06:59 PM
Drop Down/List w/Code and Definition, only code entered when selec Spiritdancer Excel Worksheet Functions 2 November 2nd 07 03:57 AM
Modification in the CODE to HIDE rows and columns that start with ZERO (code given) Thulasiram[_2_] Excel Programming 4 September 26th 06 04:15 AM
Excel code convert to Access code - Concat & eliminate duplicates italia Excel Programming 1 September 12th 06 12:14 AM
stubborn Excel crash when editing code with code, one solution Brian Murphy Excel Programming 0 February 20th 05 05:56 AM


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