LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Copying

I would like:

Open a workbook with a macro and check if the sheets "list of houses"
and "database" are in that file. And, if yes, the sheets must be
copied to myfile. In both cases the opened file must be closed (after
checking / copying).

But, If the sheets are not available, the file doesn't close and I
don't understand why.

Any help would be appriciated.

------------

Sub importerendb()
Dim bk As Workbook
Range("rekenvel!E2").Value = Range("rekenvel!b13").Value & "\" &
importeren.databasescombo.Value & ".xls"
Dim bestandsnaam
bestandsnaam = Range("rekenvel!E2").Value
Workbooks.Open Filename:=bestandsnaam, Password:="abc"
For Each n In ActiveWorkbook.Names
n.Delete
Next
Dim sh As Worksheet
On Error Resume Next
Set sh = ActiveWorkbook.Worksheets("list of houses")
If Err < 0 Then
bk.Close SaveChanges:=False
MsgBox "No list of houses found"
Else
Set sh = ActiveWorkbook.Worksheets("database")
If Err < 0 Then
bk.Close SaveChanges:=False
MsgBox "No database found"
Else

Sheets(Array("lijstkerken", "database")).Move Befo=Workbooks( _
"myfile.xls").Sheets(1)
bk.Close SaveChanges:=False
End If
End If
Unload importeren
End Sub

 
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
Copying everything KRK New Users to Excel 4 November 18th 09 11:35 PM
copying the Hyperlink function result without copying the actual formula mcheng Excel Worksheet Functions 2 June 9th 07 02:43 AM
TextBox copying not like windows copying, heh? Antoine Excel Programming 3 August 16th 05 03:35 PM
Copying in VBA [email protected] Excel Programming 2 April 25th 05 02:22 PM
Copying data down to next dirty cell, then copying that data slarson Excel Programming 0 September 15th 03 09:19 PM


All times are GMT +1. The time now is 03:41 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"