Quantcast
Channel: Excel Help Forum - Excel Programming / VBA / Macros
Viewing all articles
Browse latest Browse all 50061

Renaming a sheet and keep cell formatting

$
0
0
Hey, I was wondering if there is a way to rename a sheet after a cell while keeping the formatting?

My format isn't anything to do with the date, it's more of a "XXX"-00-00 style, so far I have my sheet being named after just the text that I input, but it would be really handy if I could keep the "XXX" beforehand.

Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
Set Target = Range("K2")
If Target = "" Then Exit Sub
On Error GoTo Badname
ActiveSheet.Name = Left(Target, 31)
Exit Sub
Badname:
MsgBox "Please revise the entry in K2." & Chr(13) _
& "It appears to contain one or more " & Chr(13) _
& "illegal characters." & Chr(13)
Range("K2").Activate
End Sub

Any help is greatly appreciated, thanks in advance!

Here is the code I have in my sheets so far:

Viewing all articles
Browse latest Browse all 50061

Trending Articles