Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default Naming multiple parameters/worksheets

Hello again,
Thanks Ron for answering my earlier question, i wont have chance to get to
my excel work till later so im just gonna ask this on measly thing before
work. If i want to add more worksheets into this code:

If SheetExists("wksht 3") = True Then

Can it be done like this?

If SheetExists("wksht 3", "wksht 4") = True Then

Or will i need some more code. If i had excel with me id try it out but i
just dont wana be faffing around later is all. If anyone can help then its
much appreciated.
Thanks in advance
Andrewbt
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default Naming multiple parameters/worksheets

Hi,

You can pass the arguments to the funxtion like this:-

If SheetExists("Sheet1") Or SheetExists("Sheet2") = True Then

or if you want to check that both exist:-

If SheetExists("Sheet1") AND SheetExists("Sheet2") = True Then

Mike

"andrewbt" wrote:

Hello again,
Thanks Ron for answering my earlier question, i wont have chance to get to
my excel work till later so im just gonna ask this on measly thing before
work. If i want to add more worksheets into this code:

If SheetExists("wksht 3") = True Then

Can it be done like this?

If SheetExists("wksht 3", "wksht 4") = True Then

Or will i need some more code. If i had excel with me id try it out but i
just dont wana be faffing around later is all. If anyone can help then its
much appreciated.
Thanks in advance
Andrewbt

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default Naming multiple parameters/worksheets

It can do it exactly that way if you change your SheetExists code


Function SheetExists(ParamArray sheets())
Dim i As Long
Dim sh As Worksheet
Dim cnt As Long

For i = LBound(sheets) To UBound(sheets)
Set sh = Nothing
On Error Resume Next
Set sh = Worksheets(sheets(i))
On Error GoTo 0
If Not sh Is Nothing Then
cnt = cnt + 1
End If
Next i

'if you want to check if any exist then use
SheetExists = cnt 0

'if you want to checl all exists then use
SheetExists = cnt = UBound(sheets) - LBound(sheets) + 1

End Function




--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"andrewbt" wrote in message
...
Hello again,
Thanks Ron for answering my earlier question, i wont have chance to get to
my excel work till later so im just gonna ask this on measly thing before
work. If i want to add more worksheets into this code:

If SheetExists("wksht 3") = True Then

Can it be done like this?

If SheetExists("wksht 3", "wksht 4") = True Then

Or will i need some more code. If i had excel with me id try it out but i
just dont wana be faffing around later is all. If anyone can help then
its
much appreciated.
Thanks in advance
Andrewbt



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
a quick way of inserting and naming multiple worksheets in Excel? Sue[_4_] Excel Worksheet Functions 5 December 4th 09 11:36 PM
Naming ranges on multiple worksheets Jim New Users to Excel 3 November 23rd 09 10:08 PM
Naming new worksheets paz24 Excel Discussion (Misc queries) 0 February 1st 06 12:46 PM
naming worksheets jerrystan[_4_] Excel Programming 6 December 16th 05 10:11 PM
Adding and Naming Multiple Worksheets Byron Excel Worksheet Functions 6 September 8th 05 02:52 AM


All times are GMT +1. The time now is 08:14 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"