Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Combibing to Excel files using VB

Status
Not open for further replies.

RHemmings

Programmer
Mar 24, 2003
6
IN
I am trying to combine two excel files into one using the code below. When I execute the code only the FIST cell of the second file gets appended. Can anyone tell me what I am doing wrong?

Thanks, Bob


Sub CombineFiles(x)
Workbooks.Open Filename:="U:\docs\PO IN.xls"
' Count rows in first file
Range("A1").Select
With Selection.CurrentRegion
rc = .Rows.Count
rc = rc + 1
End With
Workbooks.Open Filename:="U:\docs\DEP IN.xls"
Range("A1").Select
Selection.Copy
ActiveWorkbook.Close
Cells(rc, 1).Select
ActiveSheet.Paste


 
You're only copying 1 cell here:
Workbooks.Open Filename:="U:\docs\DEP IN.xls"
Range("A1").Select

Try:
Workbooks.Open Filename:="U:\docs\DEP IN.xls"
Cells.Select

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'People who live in windowed environments shouldn't cast pointers.'
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top