![]() |
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 |
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 |
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 |
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 |
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 |
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 |
All times are GMT +1. The time now is 10:59 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com