Solved

change the format of a column in a excel spredsheet

Posted on 2013-05-23
5
374 Views
Last Modified: 2013-05-27
Hi Experts, I have a excel SS that is created and one of the fields is coming out as mm/dd/yy how can I write a macro to change that columns format to yyyymmdd. Thanks for any help.
0
Comment
Question by:needhelpfast569
  • 3
  • 2
5 Comments
 
LVL 19

Expert Comment

by:helpfinder
ID: 39192254
Hi, do you need to perform this only with macro for some special reason?
because you can simple format cell(s) and set custom format yyyymmdd
0
 

Author Comment

by:needhelpfast569
ID: 39192285
the file is being created from access and the file is created as a new file each time and overwrites the existing file. I tried that one.
0
 
LVL 19

Expert Comment

by:helpfinder
ID: 39192333
so try this macro

Sub FormatChange()
    Range("A1:A3").Select
    Selection.NumberFormat = "yyyymmdd"
End Sub
0
 

Author Comment

by:needhelpfast569
ID: 39194282
Hi helpfinder, that works great do you know how I can set that macro to run after the file is built from ms access?
0
 
LVL 19

Accepted Solution

by:
helpfinder earned 500 total points
ID: 39194487
Unfortunately this I do not know. But I know how to run macro when that file is open, if it is enough for you.

You just open that Visual Basic and double click ThisWorkBook. From left drop down menu where General is by default choose Workbook and from right drop down menu choose Open. I generates a part of code for you. BEtween the lines you will call the macro I posted above, so it will looks like:
Private Sub Workbook_Open()
Call FormatChange
End Sub

This makes macro to run every time file is opened

I am attaching also sample where this is working (try to change dates in A1-A3 e.g. to 1.1.1960, 12.4.1984 etc, save the file, close it and reopen.
format-date.xlsm
0

Featured Post

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

Recently Microsoft released a brand new function called CONCAT. It's supposed to replace its predecessor CONCATENATE. But how does it work? And what's new? In this article, we take a closer look at all of this - we even included an exercise file for…
In this article we discuss how to recover the missing Outlook 2011 for Mac data like Emails and Contacts manually.
The viewer will learn how to  create a slide that will launch other presentations in Microsoft PowerPoint. In the finished slide, each item launches a new PowerPoint presentation and when each is finished it automatically comes back to this slide: …
Learn how to create and modify your own paragraph styles in Microsoft Word. This can be helpful when wanting to make consistently referenced styles throughout a document or template.

911 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

Need Help in Real-Time?

Connect with top rated Experts

26 Experts available now in Live!

Get 1:1 Help Now