Create and rename new sheets using VBA.
Posted by Joakim B on May 18, 2000 6:37 AM
I have a "small" problems with VBA in Excel. I want to that sheet "Test" shall be created if it doesent exists otherwise, you hav to fill in a new name in a box. And the new namnet mustn't exist among the sheets in workbook. If it exists then shall the box run again.
Shold be very grateful for hints / solution on this small problems.
A part of the code:
Sheets.Add
ActiveSheet.Name = "Test"
Sheets("Test").Move After:=Sheets(3)
I have tried with following but ...
Sheets.Add
If Error Then GoTo bugs
bugs: ActiveSheet.Name = InputBox("Give name.")
GoTo back
ActiveSheet.Name = "Test"
back: ActiveSheet.Move After:=Sheets(3)
Best regards Joakim Björnberg