Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
|
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 16th, 2011, 01:56 PM
Authorized User
 
Join Date: May 2011
Posts: 14
Thanks: 3
Thanked 0 Times in 0 Posts
Default how to copy a.xls and b.xls to c.xls .

hi ,

i have two sheets a.xls and b.xls i want to copy it to c.xls . It should be like first all contents of a.xls is copied then contents of b.xls are copied . in sequence .
 
Old November 16th, 2011, 10:15 PM
Friend of Wrox
 
Join Date: Sep 2005
Posts: 812
Thanks: 1
Thanked 53 Times in 49 Posts
Default

There are lot of ways to do this

Copy the usedrange of each excel in to the new one

Merge the excel sheets (http://video.about.com/spreadsheets/...s-in-Excel.htm)

Have a look at this and select the best one

Cheers
Shasur
__________________
C# Code Snippets (http://www.dotnetdud.blogspot.com)

VBA Tips & Tricks (http://www.vbadud.blogspot.com)
 
Old November 17th, 2011, 03:39 AM
Authorized User
 
Join Date: May 2011
Posts: 14
Thanks: 3
Thanked 0 Times in 0 Posts
Default

thanks ....................

Last edited by honey26; December 4th, 2011 at 04:00 PM..
 
Old November 17th, 2011, 08:29 AM
Friend of Wrox
 
Join Date: Sep 2005
Posts: 812
Thanks: 1
Thanked 53 Times in 49 Posts
Default

Hi

Here is a hint

Code:
Sub ad1()
Dim i1 As Long
Dim oWBC As Workbook
Dim oWBA As Workbook
Dim oWBB As Workbook
Set oWBC = Workbooks.Add
Set oWBA = Workbooks.Open("c:\1.xls")
oWBA.Sheets(1).UsedRange.Copy oWBC.Sheets(1).Range("A1")
oWBA.Close (False)
i1 = oWBC.Sheets(1).Cells.SpecialCells(xlCellTypeLastCell).Row + 1
Set oWBB = Workbooks.Open("c:\2.xls")
oWBB.Sheets(1).UsedRange.Copy oWBC.Sheets(1).Range("A" & i1)
oWBB.Close (False)
oWBC.SaveAs "c:\3.xls"
oWBC.Close (False)
 
End Sub
If you want to schedule every week, it would be better if you can develop the same in Vb6 / .NET and create an Exe. You can then add this Exe in Windows Scheduler

Cheers
Shasur
__________________
C# Code Snippets (http://www.dotnetdud.blogspot.com)

VBA Tips & Tricks (http://www.vbadud.blogspot.com)
The Following User Says Thank You to Shasur For This Useful Post:
honey26 (November 17th, 2011)
 
Old November 17th, 2011, 09:28 AM
Authorized User
 
Join Date: May 2011
Posts: 14
Thanks: 3
Thanked 0 Times in 0 Posts
Default

Thanks .........

Last edited by honey26; December 4th, 2011 at 04:00 PM..
 
Old November 17th, 2011, 12:34 PM
Friend of Wrox
 
Join Date: Sep 2005
Posts: 812
Thanks: 1
Thanked 53 Times in 49 Posts
Default

Then have a for loop
Code:
Sub ad1()
Dim i1 As Long
Dim oWBC As Workbook
Dim oWBA As Workbook
Dim oWBB As Workbook
Set oWBC = Workbooks.Add
For i = 1 to 10
i1 = oWBC.Sheets(1).Cells.SpecialCells(xlCellTypeLastCell).Row + 1
Set oWBB = Workbooks.Open("c:\" & i & ".xls")
oWBB.Sheets(1).UsedRange.Copy oWBC.Sheets(1).Range("A" & i1)
oWBB.Close (False)
Next i
oWBC.SaveAs "c:\Master.xls"
oWBC.Close (False)
 
End Sub
Cheers
Shasur
__________________
C# Code Snippets (http://www.dotnetdud.blogspot.com)

VBA Tips & Tricks (http://www.vbadud.blogspot.com)





Similar Threads
Thread Thread Starter Forum Replies Last Post
Help! how to read the file of *.xls hussar91404 C# 4 April 25th, 2014 03:41 AM
Inventory_Worksheet.xls HenrikFromCopenhagen BOOK: Knight's 24-Hour Trainer: Microsoft SQL Server 2008 Integration Services 2 July 10th, 2011 11:53 AM
Copy XLT as XLS, controls are missing vinodjv C# 1 July 3rd, 2008 07:24 AM
import xls or html Nathalie Beginning VB 6 3 April 26th, 2006 11:48 AM
.mpp to .xls sachin-csharp .NET Framework 2.0 0 November 1st, 2004 12:25 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.