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: 57
Default Test for for sheets existance

Hi

I'm trying to use the following code to loop through the defined range. Take
the cell value and concatenate with the term MIS.

Test if a sheet exists named the same as the concatenated term.

Then use message box to display the sheet name and then True or False.

The problem I am having with my code is that in tests it works fine upto it
finds a sheet that is True. Then even if no further sheets exist the
SheetExists variable remains True.

The Message box code will eventually be replaced by code to e-mail the sheet
if it does exist.

Can some one pont out where i went wrong and explain how to correct.

Thanks in advance.

Francis.

Public Sub testexist()
Dim SheetExists As Boolean
Dim prange As range
Dim SName As String
Set prange = Workbooks("TeamPlotter2").Worksheets("MainPage").r ange
_("A6:A17")

For Each ADV In prange


SName = ADV.Value & "MIS"

On Error Resume Next
SheetExists = CBool(Not Workbooks("TeamPlotter2").Worksheets(SName) _
Is Nothing)
On Error GoTo 0
MsgBox SName & " " & SheetExists
Next ADV
End Sub

 
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 test for the existance of a worksheet. Tom Peacock Excel Programming 4 October 4th 05 03:32 PM
Check for Existance of sheet - problem with UDF PC[_3_] Excel Programming 3 April 8th 05 12:44 PM
How to check for the existance of a Sheet (or not) Pete[_22_] Excel Programming 2 April 5th 05 04:27 PM
error handling - check chart existance annette2002[_2_] Excel Programming 1 June 9th 04 06:03 AM
Existance Check Fails ChuckM[_2_] Excel Programming 7 January 31st 04 03:02 AM


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