Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

change the format of a column in a excel spredsheet

Posted on 2013-05-23
5
Medium Priority
?
402 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 2000 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

Survive A High-Traffic Event with Percona

Your application or website rely on your database to deliver information about products and services to your customers. You can’t afford to have your database lose performance, lose availability or become unresponsive – even for just a few minutes.

Question has a verified solution.

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

This article helps those who get the 0xc004d307 error when trying to rearm (reset the license) Office 2013 in a Virtual Desktop Infrastructure (VDI) and/or those trying to prep the master image for Microsoft Key Management (KMS) activation. (i.e.- C…
After seeing numerous questions for Dynamic Data Validation I notice that most have used Visual Basic to solve the problem. This suggestion is purely formula based and can be used in multiple rows.
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

670 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