Solved

Changing date format in row one

Posted on 2014-11-12
7
82 Views
Last Modified: 2014-11-13
Hi,
I get emailed a workbook each week with updated figures that we have to ship to the customer.
Problem is, that the dates in row 1 have the following format '141112' etc etc. meaning 12/11/14 and so on.
Is there a formula or maybe vba code that I could use that would change the dates around to read 12/11/14 etc instead of 141112 ?
I have attached the workbook in question.
Your help as always is much appreciated.
wk-46.xlsx
0
Comment
Question by:Stephen Byrom
7 Comments
 
LVL 24

Expert Comment

by:NVIT
ID: 40438640
Are row 1 items from columns X and on also dates?

This works for columns E to W only:
Open your xls.
Save as .txt.
Open the .txt. The Import wizard should start.
Pick Comma delimiter.
Change Column data format to YMD.
Scroll to right and select columns E to W.
Finish.
0
 
LVL 47

Expert Comment

by:Wayne Taylor (webtubbs)
ID: 40438844
Is that format YYMMDD? If so, use this formula...

     =DATE(LEFT(A1, 2)+100, MID(A1, 3, 2), RIGHT(A1, 2))

...where A1 contains your date.
0
 
LVL 47

Expert Comment

by:Wayne Taylor (webtubbs)
ID: 40438859
If it's VBA you are after, select the cells to modify then run this macro...

Sub ChangeDateFormat()

    Dim cell As Range
    For Each cell In Selection
        If Len(cell) = 6 Then
            cell = DateSerial(Left(cell, 2), Mid(cell, 3, 2), Right(cell, 2))
        End If
    Next
    
End Sub

Open in new window

0
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
LVL 7

Expert Comment

by:tomfarrar
ID: 40438862
So the month is the last 2 digits on the right?  

Does that make sense for column F value 141113?  That would be month 13, or Jan 11, 2015?  Is that what you are saying?  

Also what is with 141201-49-W "date" starting in Column X?  Thanks.
0
 
LVL 18

Accepted Solution

by:
krishnakrkc earned 500 total points
ID: 40439146
Select the date range and run this macro.

Sub kTest()
    
    Dim x   As String
    
    With Selection
        x = .Address
        .Value = Evaluate("if(len(" & x & "),text(text((20&left(" & x & ",6))+0,""0000-00-00"")+0,""dd/mm/yyyy"")&if(len(" & x & ")>6,mid(" & x & ",7,25),""""),"""")")
    End With
    
End Sub

Open in new window


Kris
0
 
LVL 1

Author Comment

by:Stephen Byrom
ID: 40439241
Thanks a lot for all the comments, I will try them out when I get to work. Regarding Tom's question about " ...Also what is with 141201-49-W "date" starting in Column X?"  The week number gets added once the dates get so far out. And I should have pointed out that the dates are European not American so the last two digits of the block of six are the days and the middle two are the month
0
 
LVL 1

Author Closing Comment

by:Stephen Byrom
ID: 40439730
Thanks a lot to all that contributed, but Kris gets the gold star. I can 'trim' the cells that contain week numbers before I run the macro.
Thanks again for your time
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Problem with a moving column in Excel 6 45
simple excel formula 4 18
Countdown Timer 2 17
Decoding a line of VBA DataSort 11 13
This tutorial explains how to create a series of drop-down lists that are dependent upon prior selections to guide (“force”) the user to make the correct selection and reduce data errors within Microsoft Excel. Excel 2010 was used for this tutorial;…
This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.

821 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question