Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Sub InvoiceCheck()
'usage If bExists("Invoice") Then Worksheets("Invoice").PrintOut End If End Sub Public Function bExists(s As String) Dim sh as Worksheet For Each sh In ActiveWorkbook.Worksheets If LCase(s) = LCase(sh.Name) Then bExists = True Exit Function End If Next bExists = False End Function -- Regards, Tom Ogilvy "Freddy" wrote in message ... Tom, if you're pressed for time, can you direct me to some reference to see sample code on the use of "Public Function" along with a Sub procedure? "Tom Ogilvy" wrote: Public Function bExists(s as String) for each sh in ActiveWorkbook.worksheets if lcase(s) = lcase(sh.name) then bExists = True exit function end if next bExists = False End Function usage If bExists("sheet1") then worksheets("sheet1").Printout else End if -- Regards, Tom Ogilvy "Freddy" wrote: My goal is to check for the existence of a worksheet named "Invoice" within an open workbook. If it exists, then print it. If not, continue with the existing macro which prints another worksheet tab which will always exist. I need to know if I can use a function to test whether the "Invoice" worksheet exists by returning a true or false value, instead of just attempting to select the worksheet and taking a risk of it not existing then writing error handling code. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Please explain YIELDMAT function | Excel Worksheet Functions | |||
Large function - Please explain | Excel Worksheet Functions | |||
Please explain function/formula | Excel Worksheet Functions | |||
can someone explain function 'ara'? | Excel Worksheet Functions | |||
Function behaviour, can someone explain please? | Excel Programming |