Detect existence of a sheet
I'm didnt search in past topics for a answer before posting...sorry. i found
this function:
Function WorksheetExists(SheetName As Variant, _
Optional WhichBook As Workbook) As Boolean
'from Chip Pearson
Dim WB As Workbook
Set WB = IIf(WhichBook Is Nothing, ThisWorkbook, WhichBook)
On Error Resume Next
WorksheetExists = CBool(Len(WB.Worksheets(SheetName).Name) 0)
End Function
i will test it.
"Cleber Inacio" escreveu:
Hi,
I'm having problems when trying to acess a sheet in a workbook if this sheet
does'nt exist. I tried some "On Error" tricks....but it dodn't worked.
Here is the piece of code where I try to activate the sheet:
...
genesis_wb.Activate
genesis_wb.Sheets(nome_al).Activate 'nome_al is a string
...
Is there a way to check if the sheet(nome_al) exist before activating it?
(without on error techniques please).
Thanks in advance!
Cleber
|