Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
a quick way of inserting and naming multiple worksheets in Excel? | Excel Worksheet Functions | |||
Naming ranges on multiple worksheets | New Users to Excel | |||
Naming new worksheets | Excel Discussion (Misc queries) | |||
naming worksheets | Excel Programming | |||
Adding and Naming Multiple Worksheets | Excel Worksheet Functions |