ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Add Worksheet (https://www.excelbanter.com/excel-programming/368873-add-worksheet.html)

T De Villiers[_83_]

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=566704


Tom Hutchins

Add Worksheet
 
I do the same thing all the time. You have to say Sheets(Sheets.Count), not
just Sheets.Count, to return a reference to the final sheet. This works:

Sub test()
Dim wks As Worksheet
Set wks = Worksheets.Add(After:=Sheets(Sheets.Count))
wks.Name = "taz"
End Sub

Hope this helps,

Hutch

"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=566704




All times are GMT +1. The time now is 02:59 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com