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: 1
Default Loop until a unique worksheet name is entered


I am trying to create a copy of a worksheet called TEMPLET & name th
new worksheet a month end date like 63005.

I am having trouble getting the code to loop until a unique name (mont
end date) is entered in the input box.

The code loops correctly as long as there is a duplication, but stop
when a unique name (month end date) is entered.

My current code is below, but I have tried loop variations with n
success. Any ideas?

Thanks a million,

mikeburg

Sub createworksheet()
Dim monthenddate As String
Dim monthendname As String
monthenddate = Application.InputBox("Enter month end dat
ex-08-31-05: ")
monthendname = Replace(monthenddate, "-", "")
If monthenddate = "" Then GoTo done
duped:
If monthendname = Sheets(monthendname).Name Then
monthenddate = Application.InputBox("A worksheet aready exists fo
" & monthendname & ", enter a different date or cancel ex-08-31-05: ")
monthendname = Replace(monthenddate, "-", "")
If monthenddate = "" Then GoTo done
End If
If monthendname = Sheets(monthendname).Name Then GoTo duped
Sheets("Templet").Copy Befo=Sheets(1)
Sheets("Templet (2)").Name = monthendname
Sheets(monthendname).Range("H1") = monthenddate
done:
End Su

--
mikebur
-----------------------------------------------------------------------
mikeburg's Profile: http://www.excelforum.com/member.php...fo&userid=2458
View this thread: http://www.excelforum.com/showthread.php?threadid=38734

 
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
Loop based on number entered in userform Richhall[_2_] Excel Worksheet Functions 1 September 17th 09 03:58 PM
Stop unique values been entered LLoyd Excel Worksheet Functions 1 April 17th 08 09:44 AM
Unique numbers entered once only Malcolm McMaster Excel Discussion (Misc queries) 5 October 12th 07 09:23 AM
worksheet loop scott[_8_] Excel Programming 8 November 17th 03 09:49 PM
How? Macro to copy range to new worksheet, name new worksheet, loop Repoman Excel Programming 9 October 9th 03 01:45 PM


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