Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Add Worksheet
Hi,the following is a simpe macro to add a worksheet, just doesnt seem to be working, mnay thanks Sub test() Set wks = Worksheets.Add(After:=(Workbook.Sheets.Count)) wks.Name = "taz" End Sub -- T De Villiers ------------------------------------------------------------------------ T De Villiers's Profile: http://www.excelforum.com/member.php...o&userid=26479 View this thread: http://www.excelforum.com/showthread...hreadid=566705 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Add Worksheet
Use this instead:
Sub test() Worksheets.Add After:=Sheets(Sheets.Count) ActiveSheet.Name = "taz" End Sub You don't need to use an object ("Set wks = ..."). Pflugs "T De Villiers" wrote: Hi,the following is a simpe macro to add a worksheet, just doesnt seem to be working, mnay thanks Sub test() Set wks = Worksheets.Add(After:=(Workbook.Sheets.Count)) wks.Name = "taz" End Sub -- T De Villiers ------------------------------------------------------------------------ T De Villiers's Profile: http://www.excelforum.com/member.php...o&userid=26479 View this thread: http://www.excelforum.com/showthread...hreadid=566705 |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Add Worksheet
Sub test()
Set wks = Worksheets.Add(After:=Worksheets(WorkSheets.Count) ) wks.Name = "taz" End Sub -- HTH Bob Phillips (replace somewhere in email address with gmail if mailing direct) "T De Villiers" wrote in message news:T.De.Villiers.2btiky_1154363006.2003@excelfor um-nospam.com... Hi,the following is a simpe macro to add a worksheet, just doesnt seem to be working, mnay thanks Sub test() Set wks = Worksheets.Add(After:=(Workbook.Sheets.Count)) wks.Name = "taz" End Sub -- T De Villiers ------------------------------------------------------------------------ T De Villiers's Profile: http://www.excelforum.com/member.php...o&userid=26479 View this thread: http://www.excelforum.com/showthread...hreadid=566705 |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Add Worksheet
Bob,
What would be the advantage in using an object in this instance? Pflugs "Bob Phillips" wrote: Sub test() Set wks = Worksheets.Add(After:=Worksheets(WorkSheets.Count) ) wks.Name = "taz" End Sub -- HTH Bob Phillips (replace somewhere in email address with gmail if mailing direct) "T De Villiers" wrote in message news:T.De.Villiers.2btiky_1154363006.2003@excelfor um-nospam.com... Hi,the following is a simpe macro to add a worksheet, just doesnt seem to be working, mnay thanks Sub test() Set wks = Worksheets.Add(After:=(Workbook.Sheets.Count)) wks.Name = "taz" End Sub -- T De Villiers ------------------------------------------------------------------------ T De Villiers's Profile: http://www.excelforum.com/member.php...o&userid=26479 View this thread: http://www.excelforum.com/showthread...hreadid=566705 |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Add Worksheet
In this instance it is difficult to say as we cannot se the context, but it
is invariably beneficial as VBA then has pre-loaded variable which is more efficient than constantly making VBA lookup the info. -- HTH Bob Phillips (replace somewhere in email address with gmail if mailing direct) "Pflugs" wrote in message ... Bob, What would be the advantage in using an object in this instance? Pflugs "Bob Phillips" wrote: Sub test() Set wks = Worksheets.Add(After:=Worksheets(WorkSheets.Count) ) wks.Name = "taz" End Sub -- HTH Bob Phillips (replace somewhere in email address with gmail if mailing direct) "T De Villiers" wrote in message news:T.De.Villiers.2btiky_1154363006.2003@excelfor um-nospam.com... Hi,the following is a simpe macro to add a worksheet, just doesnt seem to be working, mnay thanks Sub test() Set wks = Worksheets.Add(After:=(Workbook.Sheets.Count)) wks.Name = "taz" End Sub -- T De Villiers ------------------------------------------------------------------------ T De Villiers's Profile: http://www.excelforum.com/member.php...o&userid=26479 View this thread: http://www.excelforum.com/showthread...hreadid=566705 |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
Add Worksheet
A bit contrived, but in theory there could be code in the _NewSheet events.
Private Sub Workbook_NewSheet(ByVal Sh As Object) Sheets(1).Activate End Sub Consequently the ActiveSheet is not what you think. Anyway, for me it always best to be as explicit as possible as to which object you are working on. NickHK "Pflugs" wrote in message ... Bob, What would be the advantage in using an object in this instance? Pflugs "Bob Phillips" wrote: Sub test() Set wks = Worksheets.Add(After:=Worksheets(WorkSheets.Count) ) wks.Name = "taz" End Sub -- HTH Bob Phillips (replace somewhere in email address with gmail if mailing direct) "T De Villiers" wrote in message news:T.De.Villiers.2btiky_1154363006.2003@excelfor um-nospam.com... Hi,the following is a simpe macro to add a worksheet, just doesnt seem to be working, mnay thanks Sub test() Set wks = Worksheets.Add(After:=(Workbook.Sheets.Count)) wks.Name = "taz" End Sub -- T De Villiers ------------------------------------------------------------------------ T De Villiers's Profile: http://www.excelforum.com/member.php...o&userid=26479 View this thread: http://www.excelforum.com/showthread...hreadid=566705 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
automatically appending newly added data on worksheet to a master list worksheet | Links and Linking in Excel | |||
plot graph from multiple worksheet as embedded chart object on every worksheet | Charts and Charting in Excel | |||
plot graph from multiple worksheet as embedded chart object on every worksheet | New Users to Excel | |||
Upload multiple text files into 1 excel worksheet + put the filename as the first column in the worksheet | Excel Worksheet Functions | |||
Attaching a JET database to an Excel Worksheet OR storing large binary data in a worksheet | Excel Programming |