excel add sheet vbs

teeheiman

New Member
Joined
Jul 17, 2006
Messages
6
Im useing the excel com application to create a excel file but when I create the sheets it doesnt come in order, is there any way I can add the sheet so that it adds it after and not before the deafult 3?
Code:
wrk.sheets.add()

Thanks,
Billy
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
Something like

Code:
Sub tst()
Sheets.Add after:=Sheets("sheet2")
End Sub
 
Upvote 0
This is the most generic way to do this. I am assuming the the 'wrk' variable is a reference pointing to a workbook and not the application...

wrk.sheets.add ,wrk.sheets(wrk.sheets.count)
 
Upvote 0
Sweet!
Great thank you very much! Works Perfect!

Also im not sure if its possible but what about being able to to create boarders on certain cells?

Thanks
 
Upvote 0
Sure it's possible. The same object model that is available to VBA is available to VBScript. If fact, I use the VBA IDE when I write VBScript interfacing with Excel with, usually, very little editing being needed. There are differences in the two variants of the language, but when working with a model such as Excel, you should run into very few problems...
 
Upvote 0
Should have said VBA Editor. VBA IDE is the VBA Interface Development Environment. (I think...)
 
Upvote 0

Forum statistics

Threads
1,225,286
Messages
6,184,064
Members
453,208
Latest member
Palo

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top