![]() |
New Sheet
Hello
How can I add a new sheet to a workbook using vba and call it a specific name (not sheet1). And if that name already exist in a sheet for the workbook call it that name + 1. |
New Sheet
Hi
try .... dim wks as worksheet set wks = worksheets.add wks.name="myname" -- Regards Frank Kabel Frankfurt, Germany schrieb im Newsbeitrag ... Hello How can I add a new sheet to a workbook using vba and call it a specific name (not sheet1). And if that name already exist in a sheet for the workbook call it that name + 1. |
New Sheet
Prior to adding the sheet, get the name. Then go through
the worksheets collection testing for the name property. Something like: For each wks in Thisworkbook.Worksheets If wks.Name=strNewName then strNewName = some other name blnDuplicate = True End If Next wks If blnDuplicate = False Then 'Add your new sheet and rename it. End If Good luck. Geof. -----Original Message----- Hello How can I add a new sheet to a workbook using vba and call it a specific name (not sheet1). And if that name already exist in a sheet for the workbook call it that name + 1. . |
New Sheet
Hello,
I get an error if the workbook already contains the worksheet "myname". How do I title the sheet "myname1" if it already exists or "myname2" if they both do ... etc. Thanks for your help. -----Original Message----- Hi try .... dim wks as worksheet set wks = worksheets.add wks.name="myname" -- Regards Frank Kabel Frankfurt, Germany schrieb im Newsbeitrag ... Hello How can I add a new sheet to a workbook using vba and call it a specific name (not sheet1). And if that name already exist in a sheet for the workbook call it that name + 1. . |
All times are GMT +1. The time now is 09:20 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com