View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
pickytweety pickytweety is offline
external usenet poster
 
Posts: 57
Default Code for avoiding slashes, ampersands, etc. when naming sheets

With wksNew
ActiveSheet.PageSetup.PrintArea = r.Address
.Name = Left(Trim(currCat), 31) 'this line is where I
need to expand
ActiveSheet.Calculate
.Cells.Copy
.Cells.PasteSpecial Paste:=xlValues, Operation:=xlNone,
SkipBlanks:=False, Transpose:=False
application.CutCopyMode = False
End With

When the above code is running, occasionally the macro will get stuck
because the currCat name contains a character, such as a slash, that Excel
cannot use in a sheet name. Can someone tell me how to write code that will
either strip out invalid sheet name characters or replace them with something
like a dash?
--
Thanks,
PTweety