• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Name a sheet by a value which is received from Input box.

c_rahul001

New Member
If we have a variable "Flname" which contains value in a string format and the value is accepted from Input Box then how can we use that variable to name a sheet. Name of the Sheet to be displayed should be the value stored in the variable or the value accepted through Input Box.


Ex. Flname = InputBox("Enter File Name :", "Creating New File...")


Here we accept the filename and it is stored in FLname. How can we use variable Flname and give name to sheet in same workbook.
 
C_rahul001


Firstly, Welcome to the Chandoo.org forums


You ask about renaming a Sheet and a File interchangeably within the question.


Workbooks are commonly called spreadsheet files

In Excel a Workbook contains 1 or several Worksheets


You can name either the Workbook or Worksheets as required


To rename a Worksheet use:

[pre]
Code:
Flname = InputBox("Enter File Name :", "Creating New File...")
ActiveSheet.Name = Flname
To save a Workbook[/b] use:

Flname = InputBox("Enter File Name :", "Creating New File...")
Dirname = "C:UsersIanDocuments" 'Change to suit
NewFile = Dirname + Flname
ActiveWorkbook.SaveAs Filename:=NewFile, FileFormat:=xlOpenXMLWorkbookMacroEnabled, CreateBackup:=False
[/pre]
 
Back
Top