Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Renaming the Worksheet through VBA

Ok, i'm trying to rename my worksheet to the contents of cell F8,
which really isn't that big of a deal. However, Cell F8 is a dat
formated as "mm/dd/yyyy" so when Excel tries to rename the worksheet
if gives me an error saying that it can't rename the worksheet becaus
the name contains invalid characters. I'ved tried reformatting the cel
itself to include only valid characters, but Excel still interprets i
the with "/" in it. So i know now that I have to tell Excel to forma
the date without the "/" in VBA, but how

--
Message posted from http://www.ExcelForum.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27
Default Renaming the Worksheet through VBA

Try:

Sub RenameWorksheet()
Dim dat As Date
dat = Range("A1").Value '02/09/2004
MsgBox dat
Dim strName As String
strName = Month(dat) & "." & Day(dat) & "." & Year(dat)
ActiveSheet.Name = strName
End Sub

-----Original Message-----
Ok, i'm trying to rename my worksheet to the contents of

cell F8,
which really isn't that big of a deal. However, Cell F8

is a date
formated as "mm/dd/yyyy" so when Excel tries to rename

the worksheet,
if gives me an error saying that it can't rename the

worksheet because
the name contains invalid characters. I'ved tried

reformatting the cell
itself to include only valid characters, but Excel still

interprets it
the with "/" in it. So i know now that I have to tell

Excel to format
the date without the "/" in VBA, but how?


---
Message posted from http://www.ExcelForum.com/

.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Renaming the Worksheet through VBA

activesheet.Name = Format(Range("F8"),"mmddyy")

or "mm_dd_yyyy"

But you should get the idea.

--
Regards,
Tom Ogilvy


"Brad" wrote in message
...
Try:

Sub RenameWorksheet()
Dim dat As Date
dat = Range("A1").Value '02/09/2004
MsgBox dat
Dim strName As String
strName = Month(dat) & "." & Day(dat) & "." & Year(dat)
ActiveSheet.Name = strName
End Sub

-----Original Message-----
Ok, i'm trying to rename my worksheet to the contents of

cell F8,
which really isn't that big of a deal. However, Cell F8

is a date
formated as "mm/dd/yyyy" so when Excel tries to rename

the worksheet,
if gives me an error saying that it can't rename the

worksheet because
the name contains invalid characters. I'ved tried

reformatting the cell
itself to include only valid characters, but Excel still

interprets it
the with "/" in it. So i know now that I have to tell

Excel to format
the date without the "/" in VBA, but how?


---
Message posted from http://www.ExcelForum.com/

.



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Renaming the Worksheet through VBA

Beautiful, that works, thanks a lot Tom! I knew the the jist of what t
do in VBA, but I just couldn't put it down right in the order so tha
it was doing what I wanted, but thanks to you, it works now, and an
another lesson in VBA learned.

Thanks man, you rock

--
Message posted from http://www.ExcelForum.com

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Renaming the Worksheet through VBA

Another way is

Activesheet.Name = Range("F8").Text

but make sure there are no / in the date format, else it will error

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"abxy " wrote in message
...
Ok, i'm trying to rename my worksheet to the contents of cell F8,
which really isn't that big of a deal. However, Cell F8 is a date
formated as "mm/dd/yyyy" so when Excel tries to rename the worksheet,
if gives me an error saying that it can't rename the worksheet because
the name contains invalid characters. I'ved tried reformatting the cell
itself to include only valid characters, but Excel still interprets it
the with "/" in it. So i know now that I have to tell Excel to format
the date without the "/" in VBA, but how?


---
Message posted from http://www.ExcelForum.com/



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Worksheet renaming jwilliam33 Excel Discussion (Misc queries) 5 December 6th 08 09:14 PM
Worksheet Renaming Eric Excel Discussion (Misc queries) 2 July 26th 07 02:44 PM
Worksheet Renaming Eric Excel Worksheet Functions 1 July 26th 07 02:38 PM
Renaming Worksheet without using mouse?? dalipsinghbisht Excel Discussion (Misc queries) 2 March 20th 06 02:47 PM
need help renaming a worksheet jonwyn Excel Discussion (Misc queries) 2 March 1st 05 08:34 PM


All times are GMT +1. The time now is 02:26 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"