Excel 2010 VBA Sheet Rename

Posted on 2014-04-06
Medium Priority
Last Modified: 2014-04-06
I am using Excel 2010 VBA with the following variable to get information from a text box for input into a spreadsheet:
    MyProject = SBINumberTextBox.Text
I have no problem with this task.

I also want to use this variable to rename the current (active) sheet.  During the renaming process, I want to start with some static text followed by the variable text.

"SBI(space)" + MyProject

So if the user enters 888 into the text box, the end result should be that the sheet is now titled SBI 888.

Is it possible to use information from a text box in this fashion?

Thanks for your expertise,

Question by:cowboywm
  • 2
LVL 43

Expert Comment

ID: 39981852
I am sure it is possible.

Another question which rises in my mind is: Why do you write this long question with all the explanations instead of simple test of ONE line of VBA code?
LVL 43

Accepted Solution

pcelba earned 1500 total points
ID: 39981861
OK, you may write:

ActiveSheet.Name = "SBI " + MyProject


Sheets(1).Name = "SBI " + MyProject


Remember some characters are not allowed in sheet names.

Restricted characters are  / \ * ? [ ]
Following characters could also be problematic in some cases  !@#$%&()+~`"':;,.|
And the sheet name length is also restricted in Excel...

Author Comment

ID: 39982068
I'll give this a try.  The reason I try to be specific is that things get lost in the writing translation.  Since there is on dialog I choose to be as clear a possible to avoid these back an forth emails.

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Technology opened people to different means of presenting information, but PowerPoint remains to be above competition. Know why PPT still works today.
Having trouble getting your hands on Dynamics 365 Field Service or Project Service trial? Worry No More!!!
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

619 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question