Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default open excel file and copy data to another file

I would like to create a macro that would do the following:

1- Open a closed Excel file located on my drive named "A" and select
the sheet named "Sheet1"
2- Copy all data from this sheet starting on cell A1 to the already
opened master Excel file named "B" on sheet named "Sheet2" cell A1.

Thanks in advance for your help.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22,906
Default open excel file and copy data to another file

Try the macro recorder.


Gord Dibben MS Excel MVP

On Thu, 7 Jan 2010 09:14:02 -0800 (PST), Norvascom
wrote:

I would like to create a macro that would do the following:

1- Open a closed Excel file located on my drive named "A" and select
the sheet named "Sheet1"
2- Copy all data from this sheet starting on cell A1 to the already
opened master Excel file named "B" on sheet named "Sheet2" cell A1.

Thanks in advance for your help.


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default open excel file and copy data to another file

On Jan 7, 12:32*pm, Gord Dibben <gorddibbATshawDOTca wrote:
Try the macro recorder.

Gord Dibben *MS Excel MVP

On Thu, 7 Jan 2010 09:14:02 -0800 (PST), Norvascom
wrote:



I would like to create a macro that would do the following:


1- Open a closed Excel file located on my drive named "A" and select
the sheet named "Sheet1"
2- Copy all data from this sheet starting on cell A1 to the already
opened master Excel file named "B" on sheet named "Sheet2" cell A1.


Thanks in advance for your help.- Hide quoted text -


- Show quoted text -


I does not work because the file to be opened is not always located in
the same place on the drive.
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 489
Default open excel file and copy data to another file

This macro will prompt the user to select where the file is, open it, copy
the data on Sheet1 to the master workbook Sheet2. I assume you will want to
call this sub from a command button in your master excel sheet. Hope this
helps! If so, let me know, click "YES" below.

Sub ImportSheet()

Dim wbkData As Variant

' select file with data to be opened
wbkData = Application.GetOpenFilename

' open the workbook
If wbkData = False Then
MsgBox "You didn't select a workbook.", vbInformation
Else
Workbooks.Open wbkData
Set wbkData = ActiveWorkbook
End If

' copy data to master workbook
ThisWorkbook.Sheets("Sheet2").Cells = wbkData.Sheets("Sheet1").Cells

' close the workbook without saving
wbkData.Close

End Sub
--
Cheers,
Ryan


"Norvascom" wrote:

On Jan 7, 12:32 pm, Gord Dibben <gorddibbATshawDOTca wrote:
Try the macro recorder.

Gord Dibben MS Excel MVP

On Thu, 7 Jan 2010 09:14:02 -0800 (PST), Norvascom
wrote:



I would like to create a macro that would do the following:


1- Open a closed Excel file located on my drive named "A" and select
the sheet named "Sheet1"
2- Copy all data from this sheet starting on cell A1 to the already
opened master Excel file named "B" on sheet named "Sheet2" cell A1.


Thanks in advance for your help.- Hide quoted text -


- Show quoted text -


I does not work because the file to be opened is not always located in
the same place on the drive.
.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22,906
Default open excel file and copy data to another file

Would have been handy if you mentioned that first time around.

But I see Ryan has posted something for you.


Gord

On Thu, 7 Jan 2010 09:50:08 -0800 (PST), Norvascom
wrote:

I does not work because the file to be opened is not always located in
the same place on the drive.


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
Open external data (varying file names) and closing file once data is retrieved Corrie Excel Programming 2 December 31st 06 09:56 PM
Open CSV file, format data and write output to a text file. BristolBloos Excel Programming 1 October 18th 05 03:50 PM
Use ADO to transfer data from open excel file to closed excel file JCanyoneer Excel Programming 1 April 1st 05 07:41 AM
How do I import text file, analyze data, export results, open next file Geoffro Excel Programming 2 March 6th 05 08:02 PM
Open delimited text file to excel without changing data in that file zohanc Excel Programming 1 October 3rd 03 01:06 AM


All times are GMT +1. The time now is 06:54 PM.

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"