View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Gert-Jan[_3_] Gert-Jan[_3_] is offline
external usenet poster
 
Posts: 11
Default Closing a workbook

Hi,

Can anyone help to make this work:

Sub CopyAndClose()
Dim filex
filex = Range("Sheets2!F2").Value
Workbooks.Open Filename:=filex, Password:="123"
Sheets("database").Select
Sheets("database").Copy Befo=Workbooks("test.xls"). _
Sheets(1)
Workbooks.Close Filename:=filex
End Sub

The error is in the last row.

Thanks, Gert-Jan