Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() 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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Check for a tab if it is exist | Excel Discussion (Misc queries) | |||
Copy Worksheet to a new Workbook creating if it doesn't exist and add more Worksheets if it does exist | Excel Programming | |||
Check if a value exist in a column | Excel Worksheet Functions | |||
Check if pivot already exist | Excel Programming | |||
check if a worksheet exist - VBA | Excel Programming |