Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old November 16th, 2011, 01:56 PM
Authorized User
Points: 58, Level: 1
Points: 58, Level: 1 Points: 58, Level: 1 Points: 58, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
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 .
Reply With Quote
  #2 (permalink)  
Old November 16th, 2011, 10:15 PM
Friend of Wrox
Points: 3,060, Level: 23
Points: 3,060, Level: 23 Points: 3,060, Level: 23 Points: 3,060, Level: 23
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Sep 2005
Location: , , .
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)
Reply With Quote
  #3 (permalink)  
Old November 17th, 2011, 03:39 AM
Authorized User
Points: 58, Level: 1
Points: 58, Level: 1 Points: 58, Level: 1 Points: 58, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
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.
Reply With Quote
  #4 (permalink)  
Old November 17th, 2011, 08:29 AM
Friend of Wrox
Points: 3,060, Level: 23
Points: 3,060, Level: 23 Points: 3,060, Level: 23 Points: 3,060, Level: 23
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Sep 2005
Location: , , .
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)
Reply With Quote
The Following User Says Thank You to Shasur For This Useful Post:
honey26 (November 17th, 2011)
  #5 (permalink)  
Old November 17th, 2011, 09:28 AM
Authorized User
Points: 58, Level: 1
Points: 58, Level: 1 Points: 58, Level: 1 Points: 58, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
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.
Reply With Quote
  #6 (permalink)  
Old November 17th, 2011, 12:34 PM
Friend of Wrox
Points: 3,060, Level: 23
Points: 3,060, Level: 23 Points: 3,060, Level: 23 Points: 3,060, Level: 23
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Sep 2005
Location: , , .
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)
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

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



All times are GMT -4. The time now is 11:43 PM.


Powered by vBulletin®
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.