PC Review


Reply
Thread Tools Rate Thread

Adding/copying Worksheet to Excel

 
 
Nicolas
Guest
Posts: n/a
 
      6th Apr 2010
I got 10 worksheets in workbook Master (file master.xls) and I wand to copy
them to the workbook B (file b.xls).
How can I do this? I need to this for few thousand files.
 
Reply With Quote
 
 
 
 
john
Guest
Posts: n/a
 
      12th Apr 2010


"Nicolas" wrote:

> I got 10 worksheets in workbook Master (file master.xls) and I wand to copy
> them to the workbook B (file b.xls).
> How can I do this? I need to this for few thousand files.


This is code sample that shows how to add new worksheet in vb.net
Dim obook As Excel.Workbook
Dim osheet As Excel.Worksheet

obook = oexcel.Workbooks.Add
osheet = oexcel.Worksheets(1)
osheet.Name = "TEST1"
osheet.Range("A1:AZ400").Interior.ColorIndex = 2
osheet.Range("A1").Font.Size = 12
osheet.Range("A1").Font.Bold = True
osheet.Range("A1:I1").Merge()
osheet.Range("A1").Value = "Excel Automation With Charts"
osheet.Range("A1").EntireColumn.AutoFit()

osheet.Range("A2").Font.Size = 12
osheet.Range("A2").Font.Bold = True
osheet.Range("A2:I2").Merge()
osheet.Range("A2").Value = "Excel Automation With Charts"
osheet.Range("A2").EntireColumn.AutoFit()

osheet = oexcel.worksheets(2)
osheet.Name = "TEST2"
osheet = oexcel.worksheets(3)
osheet.Name = "TEST3"

'add worksheet
osheet = CType(obook.Worksheets.Add(), Excel.Worksheet)
osheet.Name = "TEST42222222222222222"
osheet.Move(After:=obook.Worksheets(obook.Worksheets.Count))

obook.SaveAs("C:\TEST1.xls")
obook.Close()
obook = Nothing
oexcel.Quit()
oexcel = Nothing


http://vbdotnettutorial.blogspot.com/search/label/Excel
 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
EXCEL SHUTS DOWN WHEN COPYING A WORKSHEET =?Utf-8?B?Uk9PRkVS?= Microsoft Excel Misc 2 8th Feb 2007 02:45 PM
Copying an excel worksheet alex Microsoft Excel Discussion 6 31st Jan 2007 07:14 AM
Copying blank excel worksheet into additional excel workbooks =?Utf-8?B?RGVi?= Microsoft Excel Misc 10 4th Feb 2005 12:25 AM
Re: Copying a worksheet in Excel Dave Peterson Microsoft Excel Misc 1 28th Jan 2005 11:43 AM
Re: Copying Excel worksheet Geoff Microsoft Access VBA Modules 0 11th Jul 2004 12:03 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:37 AM.