Rename Sheets (With Variable Name) in Workbook Excel

How Can rename all Sheets into Excel Workbook, if each Sheet have Variable Name, and how can save each Sheet Name in (Variable Activitie).

Example: My Excel Woorkbook name´s “BD Users”

Sheet1 name´s “Users 20-10-2019”
Sheet2 name´s “Users 21-10-2019”
Sheet3 name´s “Users 22-10-2019”

I need change each Sheets Name for…

Sheet1 name´s = “1”
Sheet2 name´s = “2”
Sheet3 name´s = “3”

To get the sheets, you can use a WorkBook application variable with the Excel Scope (in its Output property). (assuming wb is the variable name for the workbook) Then, use wb.GetSheets() which is a collection of the sheet names as strings. You can filter, sort, or other things with it since it’s an array. You can run them through a For Each and Read each sheet, or in your case, rename each sheet. An example of for each would be like For each sh In wb.GetSheets, or to just get the first sheet you can use wb.GetSheets(0).

Note: GetSheets() can have errors if the excel file has a chart as a sheet, which I have run into before.

To rename the sheet, you can look into the Excel extended activity package or other Excel packages out there in the Go/Community Feed which may have a Rename Sheet activity. Or if you don’t want an activity, just use the Alt-key combination to rename the sheet ("[k(alt)]hor"+newsheetname+"[k(enter)]" I believe is the key combination if I remember right)

Regards.

2 Likes

Thanks so much!!!

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.