Home |
Search |
Today's Posts |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi,
I need to check only once (not loop) whether particular sheet is already opened or not. I would like to use If else condition based on above mentioned sheet. How can i do this. I have tried your code and found that even if the file is not there is proceeds instead of going to endif. Pl. help. Regards "Dave Ramage" wrote: The most efficient way is to trap the resulting error and process accordingly, e.g. On Error Resume Next Sheets("book7").Activate If Err.Number = 9 then Msgbox "book7 not found" End If On Error Goto 0 If this is not desired then you will have to loop through all sheets in the active workbook to see if one of them is named "book7" Function WorkSheetExists(strName as String) As Boolean Dim w as Object For Each w In ActiveWorkbook.Sheets If w.Name = strName Then WorkSheetExists = True End If Next w End Function Cheers, Dave "Vijay Kotian" wrote: While working on various sheets some times i get a error message if the sheet is not there i would like to check prior to activating it. Is there any command available to check the sheets e.g. book7 or book9 etc. |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
VBA to check is someone else has a workbook open | Excel Discussion (Misc queries) | |||
check for worksheets | Excel Worksheet Functions | |||
Check if a document is open | Excel Programming | |||
Check if workbook open | Excel Discussion (Misc queries) | |||
check if file already is open | Excel Programming |