Nikhil Damle
New Member
- Joined
- Jul 20, 2011
- Messages
- 2
I have written macro which loops through all rows in workbook and search if sheet already exist in another workbook. Here is the exact code
orderno = ThisWorkbook.Sheets("Sheet1").Range("V" & activerow).Value
Workbooks.Open (workdir & "Material Account\" & VendorName & ".xls")
Dim sh As Worksheet, iExist As Boolean
iExist = True
Set sh = Nothing
Set sh = Worksheets(orderno) 'Here is where err occur
If Err Then iExist = False
If iExist = True Then 'Sheet Exist
Else 'Sheet Does Not Exist
End if
ActiveWorkbook.Save
ActiveWorkbook.Close
This code generates overflow error(Run time error 6) and adding On Error Resume Next Does not search sheet. How to rectify this or is there any other way to search sheet in another workbook.
Thanks in Advance
orderno = ThisWorkbook.Sheets("Sheet1").Range("V" & activerow).Value
Workbooks.Open (workdir & "Material Account\" & VendorName & ".xls")
Dim sh As Worksheet, iExist As Boolean
iExist = True
Set sh = Nothing
Set sh = Worksheets(orderno) 'Here is where err occur
If Err Then iExist = False
If iExist = True Then 'Sheet Exist
Else 'Sheet Does Not Exist
End if
ActiveWorkbook.Save
ActiveWorkbook.Close
This code generates overflow error(Run time error 6) and adding On Error Resume Next Does not search sheet. How to rectify this or is there any other way to search sheet in another workbook.
Thanks in Advance