Add input box to rename sheet

Last Edited By Krjb Donovan
Last Updated: Mar 07, 2014 05:18 PM GMT

QuestionEdit

Microsoft2007..

I am a fairly new user of VBA.

How would I add a sheet a report and then add an input box to rename it.


AnswerEdit

You didn't give me any clues about what sort of sheet needed to be added - so I've assumed a blank worksheet

Sub workbookadder() On Error GoTo retry Dim mysht As Worksheet Set mysht = Worksheets.Add reinput: mysht.Name = InputBox("Please type the name for this sheet") Exit Sub retry: MsgBox "That name either already exists or is not allowed. Please retry" GoTo reinput End Sub

Advertisement

©2024 eLuminary LLC. All rights reserved.