VBSCript code to rename excel sheet;Rename Excel Sheet VBScript;Excel sheet rename using VBScript;Excel sheet rename programmatically VBScript
How to rename Excel worksheet from VBScript
1) The following code renames an excel worksheet in VBScript.
To rename an excel sheet we need to open the excel file, rename the sheets, save and close it. Now we can start coding to open and rename the first excel sheet from "Sheet1" to "NewName".
To rename an excel sheet we need to open the excel file, rename the sheets, save and close it. Now we can start coding to open and rename the first excel sheet from "Sheet1" to "NewName".
1. Create a file ExcelRename.vbs and paste the below VBScript Code
':: How to rename Excel worksheet from VBScript '---------------------------------------------- 'create the excel object Set objExcel = CreateObject("Excel.Application") 'view the excel program and file, set to false to hide the whole process objExcel.Visible = True 'turn off screen alerts objExcel.DisplayAlerts = False 'open an excel file (make sure to change the location) .xls for 2003 or earlier Set objWorkbook = objExcel.Workbooks.Open("C:\Viji\Test.xlsx") 'Use objWorkbook.Worksheets.count to get the count of sheets 'Get the first sheet Set objWorksheet = objWorkbook.Worksheets(1) 'Rename the sheet objWorksheet.Name = "NewName" 'save the existing excel file. use SaveAs to save it as something else objWorkbook.Save 'close the workbook objWorkbook.Close 'exit the excel program objExcel.Quit 'release objects Set objExcel = Nothing Set objWorkbook = Nothing
2. Double click ExcelRename.vbs to execute. The sheet has been renamed from "Sheet1" to "NewName"
After rename |
It's so simple !!!! Happy Coding.
very nice and provide me informative content thanks for sharing for more information about Rename Sheet in Excel
ReplyDeleteReally Happy to say your post is very interesting. Keep sharing your information regularly for my future reference. Thanks Again.
ReplyDeleteTop Big Data Companies
Top Data Analytics Companies
Top text analytics Companies
Top Software testing companies
Top Machine Learning Companies
Top Mobile App Development Companies
Very good piece my friend, I like it's complete even with open and close instance.
ReplyDeleteThank you so much! I came to your script since I needed an specific information on how to rename sheets using VBS! thank you for the complete content
ReplyDeleteThis blog is really great. The information here will surely be of some help to me. Thanks!. names ideas
ReplyDeleteI got too much interesting stuff on your blog. I guess I am not the only one having all the enjoyment here! Keep up the good work. tech company names
ReplyDeleteThank you for sharing such a valuable and easily digestible article. Visit this profile Mental age quiz. Push your brain with this enjoyable mental age assessment!
ReplyDelete