Removing invalid characters from proposed sheet name

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am wanting to enter data on a sheet and then rename the sheet as the cell contents of a particular cell on the sheet. by programmatically pasting the cell contents as the sheetname. Trouble is the contents of the sheet are set by users and they have used chracters such as / or \ within the cell. Is there a simple way of removing such characters?

TIA
 
newName = Application.Substitute(activecell.value, "/", "")

Bob Flanagan
Macro Systems
http://www.add-ins.com
Productivity add-ins and downloadable books on VB macros for Excel

Ron McCormick said:
I am wanting to enter data on a sheet and then rename the sheet as the
cell contents of a particular cell on the sheet. by programmatically
pasting the cell contents as the sheetname. Trouble is the contents of the
sheet are set by users and they have used chracters such as / or \ within
the cell. Is there a simple way of removing such characters?
 
that is pretty limited

Try something like this: In the Worksheets Change event put in this code

Private Sub Worksheet_Change(ByVal Target As Range
Set isect = Application.Intersect(Target, Range("a1")
If Not isect Is Nothing and Target.Value <> "" The
for x = 1 to Len(Target.Value
If Mid(Target, x,1) Not Like "[A-Za-z0-9]" the
Msgbox "Use Letters and Numbers Only!
Target.Selec
Target.Value=""
End I
End i
End Sub
----- Bob Flanagan wrote: ----


newName = Application.Substitute(activecell.value, "/", ""

Bob Flanaga
Macro System
http://www.add-ins.co
Productivity add-ins and downloadable books on VB macros for Exce

Ron McCormick said:
I am wanting to enter data on a sheet and then rename the sheet as th
cell contents of a particular cell on the sheet. by programmaticall
pasting the cell contents as the sheetname. Trouble is the contents of th
sheet are set by users and they have used chracters such as / or \ withi
the cell. Is there a simple way of removing such characters
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top