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!

How do you add a worksheet to a workbook in excel using .vbs

Status
Not open for further replies.

Stephon98caffe

Programmer
Feb 18, 2005
25
US
I know how to open an excel spread sheet using .vbs. I have a huge list of data but I want to separate each OU on the same workbook but on different sheets. How do you access each sheet within a workbook?
 
I know how to open an excel spread sheet using .vbs
Any chance you could post what you have tried so far and where you're stuck.
Have a look at the Sheets collection of the Excel.Workbook object.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Just browsing through some old posts and came across this one; not sure if Stephon98caffe has already solved this one or not, but just incase someone else comes across this post.
Will add one additional sheet and name all four:
Code:
Set oXLS = CreateObject("Excel.Application")

oXLS.Visible = TRUE
oXLS.Workbooks.Add

'Adds one spreadsheet to book
oXLS.ActiveWorkbook.Worksheets.Add

oXLS.Sheets(1).Name = "ONE"
oXLS.Sheets(2).Name = "TWO"
oXLS.Sheets(3).Name = "THREE"
oXLS.Sheets(4).Name = "FOUR"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top