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 Check for existing sheet in book


Hi,

Wondering if anyone can help me out. I have a button on a template
worksheet that when clicked, copies the template and renames it using
the contents of a ComboBox (cmbSelectYear). Code below:


Private Sub CommandButton1_Click()
Dim StrName As String

StrName = cmbSelectYear

Worksheets("Template").Copy Worksheets(1)
ActiveSheet.Name = StrName

End Sub
===========================================

I need to add code to this same click event that will check for the
existence of a sheet with the same name before copying and renaming. If
a sheet doesnt exist to thencontinue normally, otherwise to exit the
sub.

Can anybody help me, or point me in the right direction?
Any help is appreciated.
Ben


--
benjammind
------------------------------------------------------------------------
benjammind's Profile: http://www.excelforum.com/member.php...o&userid=18217
View this thread: http://www.excelforum.com/showthread...hreadid=382450

 
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 I stopped a Book 1 opening with existing files sirbob Excel Discussion (Misc queries) 0 April 4th 06 07:01 PM
How do I stop Book 1 opening with existing files? sirbob Excel Discussion (Misc queries) 2 April 3rd 06 10:18 AM
Blank workbook opens when try to open any existing book poloboyUK Excel Discussion (Misc queries) 2 February 2nd 06 08:35 PM
formula for check book Mike Busch Excel Discussion (Misc queries) 3 August 19th 05 12:10 AM
Open book, check for macros, close book Robin Hammond[_2_] Excel Programming 5 March 31st 05 06:09 PM


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