Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
LizzieHW
 
Posts: n/a
Default How do I check for existence of a worksheet?

I'm trying to create a number of new worksheets based on the information in a
column on the original worksheet, and then copy the information from the
original sheet onto the relevent new sheet. I want to trap errors by first
checking if the required sheet exists before trying to create it, but I don't
know how to do this.
  #2   Report Post  
Ron de Bruin
 
Posts: n/a
Default

Hi Lizzie

You can copy this function in a normal module

Function SheetExists(SName As String, _
Optional ByVal WB As Workbook) As Boolean
'Chip Pearson
On Error Resume Next
If WB Is Nothing Then Set WB = ThisWorkbook
SheetExists = CBool(Len(WB.Sheets(SName).Name))
End Function

And use this in your code in your loop

If SheetExists(cell.Value) = False Then



--
Regards Ron de Bruin
http://www.rondebruin.nl


"LizzieHW" wrote in message ...
I'm trying to create a number of new worksheets based on the information in a
column on the original worksheet, and then copy the information from the
original sheet onto the relevent new sheet. I want to trap errors by first
checking if the required sheet exists before trying to create it, but I don't
know how to do this.



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
Only calculate specific worksheet automatically? qflyer Excel Worksheet Functions 1 June 27th 05 09:52 PM
Linking cells in a worksheet to other worksheets in a workbook Dave Excel Discussion (Misc queries) 4 June 24th 05 06:18 PM
IF WorkSheet1 A1=1 then put value of WS1 B2 in WS2 C3 else donothi DeVon Excel Worksheet Functions 1 February 5th 05 05:05 AM
drop down menu containing worksheet names J-Rad Excel Worksheet Functions 3 February 1st 05 03:25 AM
copyright and worksheet protection dow Excel Discussion (Misc queries) 2 January 3rd 05 03:07 PM


All times are GMT +1. The time now is 01:01 PM.

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"