Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
dan dan is offline
external usenet poster
 
Posts: 15
Default Import from another Workbook

In Workbook 1, I am running a macro that uses this code to select a
file and copy A:Z on the main worksheet:

Dim myBk As Workbook
Set myBk = Workbooks.Open(Application.GetOpenFilename _
(, , "Select the file"))
Sheets("Main").Select
Range("A:Z").Copy

Next, I want it to switch back to Workbook 1, insert a new worksheet,
paste the data, and name the worksheet "rawdata".

Any suggestions for me? I basically have a workbook I'm starting from,
I want to open a dialog box to allow the user to select another excel
file (filenames can be different so I want user to select), and then
import a specific worksheet from that workbook into my starting
workbook.

Any help would be greatly appreciated, Thanks!

Dan

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Import from another Workbook

Try this

Sub test()
Dim myBk As Workbook
Dim Basesheet As Worksheet
Set Basesheet = Sheets.Add
Basesheet.Name = "rawdata"
Set myBk = Workbooks.Open(Application.GetOpenFilename _
(, , "Select the file"))

myBk.Sheets("Main").Range("A:Z").Copy Basesheet.Range("A1")
myBk.Close False
End Sub

Are you sure that the workbook you select have a sheet named Main

--
Regards Ron de Bruin
http://www.rondebruin.nl



"dan" wrote in message ups.com...
In Workbook 1, I am running a macro that uses this code to select a
file and copy A:Z on the main worksheet:

Dim myBk As Workbook
Set myBk = Workbooks.Open(Application.GetOpenFilename _
(, , "Select the file"))
Sheets("Main").Select
Range("A:Z").Copy

Next, I want it to switch back to Workbook 1, insert a new worksheet,
paste the data, and name the worksheet "rawdata".

Any suggestions for me? I basically have a workbook I'm starting from,
I want to open a dialog box to allow the user to select another excel
file (filenames can be different so I want user to select), and then
import a specific worksheet from that workbook into my starting
workbook.

Any help would be greatly appreciated, Thanks!

Dan



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Import from another Workbook

You have another response in .excel

dan wrote:

In Workbook 1, I am running a macro that uses this code to select a
file and copy A:Z on the main worksheet:

Dim myBk As Workbook
Set myBk = Workbooks.Open(Application.GetOpenFilename _
(, , "Select the file"))
Sheets("Main").Select
Range("A:Z").Copy

Next, I want it to switch back to Workbook 1, insert a new worksheet,
paste the data, and name the worksheet "rawdata".

Any suggestions for me? I basically have a workbook I'm starting from,
I want to open a dialog box to allow the user to select another excel
file (filenames can be different so I want user to select), and then
import a specific worksheet from that workbook into my starting
workbook.

Any help would be greatly appreciated, Thanks!

Dan


--

Dave Peterson
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
Import worksheets from another workbook? bjwheeler Excel Worksheet Functions 1 April 13th 09 05:24 PM
How do I import one workbook into another? jkarennj Excel Discussion (Misc queries) 1 June 26th 08 04:22 PM
IMPORT DATA from the same Workbook Ananth Excel Discussion (Misc queries) 1 August 1st 07 06:08 AM
Import/Copy some data from one workbook to a similar workbook [email protected] Excel Programming 11 March 7th 06 12:34 PM
How do I import an XLT worksheet into another workbook? chris5 Excel Programming 3 October 5th 05 12:38 PM


All times are GMT +1. The time now is 07:22 AM.

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"