Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Import Data from 2 Workbooks in the same folder

Hi All,

I would appreciate some assistance with the following:

1. I have three excel workbooks in a folder. The name of the first
workbook starts with the letter "P". The second workbook's name
starts with "S" and the third is called Daily Recon.

2. Workbooks P and S represent data dumps from two different systems.
The Daily Recon consolidates the data dumpts from the P and S
workbooks.

3. Each day these three files are saved in a new folder named after
the day the data dumps correspond to. For example Mar 1, Mar 2 etc.

4. I would like to add a button in the Daily Recon workbook called
"Import" which will import the data on the first worksheet of the
workbook named "P" starting at row 10 to column J and down for
as many rows as there is data into a worksheet in the Daily Recon
workbook called "P". At the same time the code should also import
the data from the "S" workbook from the first worksheet but starting
at row 1 to column m and down for as many rows as there is data into
a worksheet named "S" in the Daily Recon workbook.

5. The Daily Recon workbook will already have two worksheets called
"P" and "S" so there is no need to insert new sheets during the import
processes.

6. I am using Excel 2002 on windows XP.

Any ideas on how to accomplish the above would be greatly appreciated.

Thanks,

Steve
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Import Data from 2 Workbooks in the same folder

I don't know your expertise in VBA or Excel. This is a starting point and I
will assit as needed by replying to my message.

The code below is a good starting point for doing your copying. It give an
example of finding the last row with data and how to copy from one file to
another. Get this code working then add a button.

The button gets added by going to the View Menu - Toolbar - Control toolbox.
Add a Command button. The Command button can be selected to run any macro.

Sub getworkbook()

Set OldWorkbook = ThisWorkbook
OldLastRow = OldWorkbook.Worksheets("sheet1"). _
Cells(1, 1).End(xlDown).Row

MyFileName = "c:\temp\abc.xls"

Workbooks.Open Filename:=MyFileName, ReadOnly:=True
' Removed pathname from file name so it can be referenced in this program.
'Basic doesn't like the full pathname???? stupid microsoft
Do While (1)
CharPosition = InStr(MyFileName, "\")
If CharPosition 0 Then
MyFileName = Mid(MyFileName, CharPosition + 1)
Else
Exit Do
End If
Loop

Lastrow = Workbooks(MyFileName). _
Worksheets("sheet1").Cells(10, 1).End(xlDown).Row
Set MyRange = Workbooks(MyFileName).Worksheets("sheet1"). _
Range(Cells(10, 1), Cells(Lastrow, 1)).EntireRow

MyRange.Copy



MyRange.Copy Destination:=OldWorkbook.Worksheets("Sheet1"). _
Cells(OldLastRow + 1, 1)



Workbooks(MyFileName).Close SaveChanges:=False

End Sub

"steve" wrote:

Hi All,

I would appreciate some assistance with the following:

1. I have three excel workbooks in a folder. The name of the first
workbook starts with the letter "P". The second workbook's name
starts with "S" and the third is called Daily Recon.

2. Workbooks P and S represent data dumps from two different systems.
The Daily Recon consolidates the data dumpts from the P and S
workbooks.

3. Each day these three files are saved in a new folder named after
the day the data dumps correspond to. For example Mar 1, Mar 2 etc.

4. I would like to add a button in the Daily Recon workbook called
"Import" which will import the data on the first worksheet of the
workbook named "P" starting at row 10 to column J and down for
as many rows as there is data into a worksheet in the Daily Recon
workbook called "P". At the same time the code should also import
the data from the "S" workbook from the first worksheet but starting
at row 1 to column m and down for as many rows as there is data into
a worksheet named "S" in the Daily Recon workbook.

5. The Daily Recon workbook will already have two worksheets called
"P" and "S" so there is no need to insert new sheets during the import
processes.

6. I am using Excel 2002 on windows XP.

Any ideas on how to accomplish the above would be greatly appreciated.

Thanks,

Steve

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 many *.tsv files in folder and import the data into Excel SunRace Excel Programming 1 March 16th 06 10:40 PM
how can I specific a folder with wildcard criteria and excel will import all the correct files in that folder? Raven Excel Discussion (Misc queries) 1 January 24th 06 03:28 PM
how can I specific a folder with wildcard criteria and excel will import all the correct files in that folder? Raven[_2_] Excel Programming 1 January 24th 06 04:23 AM
How do I change the default folder when I import data? marvmart Excel Worksheet Functions 0 January 11th 06 04:58 PM
exporting data from Workbooks in Folder juergenkemeter Excel Programming 0 December 23rd 05 12:46 AM


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