View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips[_6_] Bob Phillips[_6_] is offline
external usenet poster
 
Posts: 11,272
Default error when sheet doesn't exist...

I think that it would be with this code

For i = 1 To 850

Application.Workbooks.Open Filename:= _
"X:\Users\Shared\GENERAL\Christian S\05.10.28 - Budget packs -Capital
expenditure - comments\Test\BFR " & Mnumb & " bud v2.1.xls" _
, UpdateLinks:=0

Aworkbook = Workbooks("BFR " & Mnumb & " bud v2.1.xls").Name


Firstly, I think you should open the file outside of the loop, then test for
existence, exit if not found


sFilename = "X:\Users\Shared\GENERAL\Christian S\05.10.28 - " & _
"Budget packs - Capital expenditure - comments\Test\BFR
" & _
Mnumb & " bud v2.1.xls"
Application.Workbooks.Open Filename:= sFilename, UpdateLinks:=0

If Not SheetExists("Sch 7A") Then Exit Sub

Aworkbook = Activeworkbook.Name

For i = 1 To 850

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Ctech" wrote in
message ...

How do I implement this function in my macro?


--
Ctech
------------------------------------------------------------------------
Ctech's Profile:

http://www.excelforum.com/member.php...o&userid=27745
View this thread: http://www.excelforum.com/showthread...hreadid=483865