Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 62
Default How to check worksheets exist or not ?


Hi NickHK
I just testing below coding. Very good result
On Error GoTo 0

Thank a lot
Moonhk


NickHK wrote:
Unless you have good reason, it is not advisable to run the whole routine
with "On Error Resume Next" active.

Make it active when you expect an error, deal with it and return to 'normal'
error handling. As in Bob's example:

On Error Resume Next
Set loCIM =Application.Workbooks("apvomt_v5.xls").Worksheets ("Detail")
On Error GoTo 0
If loCIM Is Nothing Then

NickHK

"moonhk" wrote in message
oups.com...
Thank, I am using below coding

Public Sub Build_CIM()
On Error Resume Next
Dim loBook As Workbook
Dim loSheet As Worksheet
Dim loBookName As String
Dim loSheetName As String
Dim loCIM As Worksheet
Dim cnt, cimCnt As Long
cim.init
loBookName = Application.ActiveWorkbook.Name
loSheetName = Application.ActiveSheet.Name
Application.StatusBar = "Processing..." & loSheetName
MsgBox loSheetName
Set loCIM =
Application.Workbooks("apvomt_v5.xls").Worksheets( "Detail")
If loCIM Is Nothing Then
MsgBox "Workbook not opened apvomt_v5.xls"
Exit Sub
End If
Set loSheet =
Application.Workbooks(loBookName).Worksheets(loShe etName)
'~~ Temp
If loSheet Is Nothing Then
MsgBox "Workbook not opened " & loBookName & " " & loSheetName
Exit Sub
End If
option
site.getConfig ("SH-451455")
cnt = 3
cimCnt = 7
'~~MsgBox site.s1dnAddr & "CIM=" & cim.s2BatchAddr
Do
'~~ Setup Invoice Value
loCIM.Range(cim.s2InvoiceAddr & cimCnt).Value = _
loSheet.Range(site.s1dnAddr & cnt).Value
'~~ Update counter
cimCnt = cimCnt + 1
cnt = cnt + 1
Loop While VBA.Trim(loSheet.Range(site.s1dnAddr & cnt)) < ""
MsgBox cnt
End Sub


Bob Phillips wrote:
On Error Resume Next
SheetExists = CBool(Not Application.Workbooks("myWorkBook") _
.Worksheets("myWorksheet") Is Nothing)
On Error GoTo 0
If SheetExists Then
Set loWS =
Application.Workbooks("myWorkBook").Worksheets("my Worksheet")


--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"moonhk" wrote in message
oups.com...
How to check worksheets exist or not ?

Dim loWS As Worksheet
Set loWS =

Application.Workbooks("myWorkBook").Worksheets("my Worksheet")



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
Check for a tab if it is exist Farhad Excel Discussion (Misc queries) 2 December 21st 08 07:31 PM
Copy Worksheet to a new Workbook creating if it doesn't exist and add more Worksheets if it does exist [email protected] Excel Programming 4 June 18th 06 06:08 PM
Check if a value exist in a column DJ Steffo Excel Worksheet Functions 1 January 30th 06 02:37 PM
Check if pivot already exist Tom Ogilvy Excel Programming 0 September 11th 03 05:43 AM
check if a worksheet exist - VBA Warren Excel Programming 1 September 10th 03 05:02 AM


All times are GMT +1. The time now is 07:07 PM.

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

About Us

"It's about Microsoft Excel"