Solved

Excel Macro Issue

Posted on 2011-02-23
2
289 Views
Last Modified: 2012-05-11
Good Afternoon,

I am using Office 2010. I have an excel file which I filter certain data and then run this macro:

Sub Save()
'
' Save Macro
'
' Keyboard Shortcut: Ctrl+Shift+M
'
    Sheets("Email Data").Select
    ChDir "C:\Documents and Settings\amyp\Desktop\Service Reminder (Temp)"
    ActiveWorkbook.SaveAs Filename:= _
        "C:\Documents and Settings\amyp\Desktop\Service Reminder (Temp)\Email Data.csv", _
        FileFormat:=xlCSV, CreateBackup:=False
    Sheets("Letter Data").Select
    ActiveWorkbook.SaveAs Filename:= _
        "C:\Documents and Settings\amyp\Desktop\Service Reminder (Temp)\Letter Data.csv" _
        , FileFormat:=xlCSV, CreateBackup:=False
    Sheets("Warranty Data").Select
    ActiveWorkbook.SaveAs Filename:= _
        "C:\Documents and Settings\amyp\Desktop\Service Reminder (Temp)\Warranty Data.csv" _
        , FileFormat:=xlCSV, CreateBackup:=False
    Sheets("CSI Data").Select
    ActiveWorkbook.SaveAs Filename:= _
        "C:\Documents and Settings\amyp\Desktop\Service Reminder (Temp)\CSI Data.csv", _
        FileFormat:=xlCSV, CreateBackup:=False
    Sheets("Agency Data").Select
    ActiveWorkbook.SaveAs Filename:= _
        "C:\Documents and Settings\amyp\Desktop\Service Reminder (Temp)\Agency Data.csv" _
        , FileFormat:=xlCSV, CreateBackup:=False
    Sheets("Company Data").Select
    ActiveWorkbook.SaveAs Filename:= _
        "C:\Documents and Settings\amyp\Desktop\Service Reminder (Temp)\Company Data.csv" _
        , FileFormat:=xlCSV, CreateBackup:=False
End Sub

When saving the data as a CSV file, all of the dates are changed from UK format of DD-MM-YYYY to American format of MM-DD-YYYY, even though the dates are shown in the correct UK format prior to running the macro.

Can anyone advise me as to why this is happening?
0
Comment
Question by:ali_
2 Comments
 
LVL 30

Expert Comment

by:SiddharthRout
ID: 34962366
0
 
LVL 23

Accepted Solution

by:
Michael74 earned 500 total points
ID: 34967458
A suggestion from this forum
http://www.excelforum.com/excel-programming/381953-date-format-problem-on-export-to-csv.html

is to change the dates in the sheet to US format before the save and then for some reason excel will then change them back to UK format on the save.

Michael
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Drop Down List with Unique/Distinct Values (Part II - ComboBox or ListBox and Data Validation List Bonus!) David Miller (dlmille) Intro This article focuses on delivering unique, sorted lists to list objects (e.g., ComboBox, ListBox) and Dat…
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;…
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.

770 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