Link to home
Start Free TrialLog in
Avatar of csehz
csehzFlag for Hungary

asked on

VBA Excel - Add sheet and rename

Dear Experts,

I have three lines in a part of a macro which simply add a new sheet and renames it

Sheets.Add
Sheets("Sheet4").Select
Sheets("Sheet4").Name = "Orders"

My problem that sometimes when the macro add a sheet, it is not Sheet4 just Sheet3 for example, and it stops the running. Could you please advise how to do this simplier so maybe in one step adding and renaming? The target would be simply just adding a new sheet as "Orders"

thanks,
SOLUTION
Avatar of MINDSUPERB
MINDSUPERB
Flag of Kuwait image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of csehz

ASKER

Thanks the solutions, for me seems simplier the option

Sheets.Add
ActiveSheet.Name = "Orders"

thanks,