+ Reply to Thread
Results 1 to 2 of 2

Date Format from dd//mm/yyyy to dd-mmm

  1. #1
    Registered User
    Join Date
    08-31-2010
    Location
    Australia
    MS-Off Ver
    Excel 2003
    Posts
    9

    Date Format from dd//mm/yyyy to dd-mmm

    Hi all,

    I'm having a slight issue with my date formats which can be seen on the attached file. I am trying to use the code (below) in VBA to change the names of a large number of worksheets. I am using the Cell C2 as the value to name the worksheet which is a vlookup from the Lists worksheet. The problem I think I am having is that the date format in column B of the 'Lists' worksheet is in the dd/mm/yyyy format even though it displays as dd-mmm-yy. Therefore when I run the code in VBA I am assuming it is picking up the "/" which cannot be used in the sheetname. Is there any way to change the format of the cell so that it is displaying say a "-" instead of "/"?

    Sub RenameWS()
    Dim ws As Worksheet
    For Each ws In ActiveWorkbook.Worksheets
    ws.Activate
    ws.Name = Range("C2").Value
    Next
    End Sub

    Thanks in advance.

    ICS
    Attached Files Attached Files

  2. #2
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,598

    Re: Date Format from dd//mm/yyyy to dd-mmm

    If you select the column of dates and change the format to Number, you'll see that the contents are actually date serial numbers. You need to change them to string values with something like
    Please Login or Register  to view this content.
    Then use the test string to name your sheets.
    Ben Van Johnson

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1