How to Rename current worksheet name in Excel

Hi All,

I want to rename my current worksheet "Sheet3" to "Output Data" in excel using Blue Prism.

Can anyone please help me in this.

Thanks in Advance!!!
 

Attachments

  • MS Excel.png
    MS Excel.png
    3.1 KB · Views: 150

VJR

Well-Known Member
Staff member
Hi Naveen,

I don't know if there are any other ways but this is one of them.
The basic idea is to -
- store the name of old sheet (may not be necessary if your old sheet name is fixed and can be hard coded)
- copy the old sheet to a new sheet
- then Delete the old one

Please refer attached screenshots. This is a working copy. Let me know if you are having any trouble.


Thanks.
 

Attachments

  • Rename sheet1.JPG
    Rename sheet1.JPG
    39.5 KB · Views: 533
  • Rename sheet2.JPG
    Rename sheet2.JPG
    40.8 KB · Views: 536
  • Rename sheet3.JPG
    Rename sheet3.JPG
    52.6 KB · Views: 485

nbargaje

Member
Hi Naveen,

I don't know if there are any other ways but this is one of them.
The basic idea is to -
- store the name of old sheet (may not be necessary if your old sheet name is fixed and can be hard coded)
- copy the old sheet to a new sheet
- then Delete the old one

Please refer attached screenshots. This is a working copy. Let me know if you are having any trouble.


Thanks.

@ VJR,
Did you find any other way to rename worksheet, if yes please let me know, i can not perform above method due to excel column duplicate issue.

Thanks,
Nitin.
 

Manikanta

Member
Hi Naveen,

I don't know if there are any other ways but this is one of them.
The basic idea is to -
- store the name of old sheet (may not be necessary if your old sheet name is fixed and can be hard coded)
- copy the old sheet to a new sheet
- then Delete the old one

Please refer attached screenshots. This is a working copy. Let me know if you are having any trouble.


Thanks.
Hopefully this is the only way to rename a worksheet.
I too done rename or check exists worksheet name or renew with different naming of a worksheet.
 

nbargaje

Member
hey,

Thanks for the reply, But I can not use above method bcoz I can not copy data to new sheet (copy paste has some issue with my excel). only way to rename tab.

I found this code for rename but getting below error,

Dim ws as Object = GetWorksheet(handle,workbookname,oldworksheetname,neworksheetname)
ws.Set=oldworksheetname
ws.Name=neworksheetname


Internal : Could not execute code stage because exception thrown by code stage: Conversion from string "newsheetname" to type 'Boolean' is not valid.


if any one can help me what I am missing any above code. I am really not good at vb.

Thanks,Nitin
 

nbargaje

Member
modified code:

Dim wb as Object
Dim ws as Object

wb=GetWorkbook(handle, workbookname)
ws.Set=wb.Worksheets("oldworksheetname")
ws.Name="neworksheetnam"

but while running getting error "given key was not present in dictionary"

can anyone what i am missing?

Thanks,
Nitin
 
Top