Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default How do I copy a worksheet form a workbook in my workbook


Hi am using the following code to open a workbook

sFileName = Application.GetOpenFilename
If sFileName = "False" Then Exit Sub
Workbooks.Open sFileName

I need to copy sheet2 from the open workbook into the workbook that is
running the above code.

Also another thought if the workbook mentioned above is already open
what is the code to stop an error showing and activating the open
workbook?

Many Thanks
Neil

*** Sent via Developersdex http://www.developersdex.com ***
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 92
Default How do I copy a worksheet form a workbook in my workbook

Hello -

The following will check whether an Excel file called aName is already
open ...

For Each lWorkbook In Workbooks
If lWorkbook.Name = aName Then
lResult = MsgBox(aName & " is already open")
...
End If
Next lWorkbook

The next code snippet will copy the specified Worksheet into a new
workbook and save it ...

ThisWorkbook.Sheets("Sheet1").Select
ThisWorkbook.Sheets("Sheet1").Copy
ActiveWorkbook.SaveAs Filename:="C:\X.xls", FileFormat:=xlNormal

Joe

Reply
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
Copy worksheet from one workbook to a master workbook mvannatta Excel Worksheet Functions 3 April 15th 09 08:32 PM
Copy Worksheet from one Workbook to another Workbook Autumn Dreams Excel Discussion (Misc queries) 5 September 12th 08 10:55 PM
Copy Data from Workbook into specific Worksheet in other Workbook? kingdt Excel Discussion (Misc queries) 1 March 16th 06 06:55 PM
copy worksheet from closed workbook to active workbook using vba mango Excel Worksheet Functions 6 December 9th 04 07:55 AM
Copy VBA Module and Form from Workbook to another workbook topaiva Excel Programming 1 November 25th 04 03:47 PM


All times are GMT +1. The time now is 02:58 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"