Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
|
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 21st, 2005, 03:11 AM
Registered User
 
Join Date: Apr 2005
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to jonwitts
Default Changing date format in a file export from excel t

I have a macro running in excel 2003 that exports date and a event text field to a javascript file, however the macro was wrote for American systems and I am in the UK. Below I have included the VBA that is responsible for the conversion of the date from "14-Jul-2004" format to "yyyymmdd" format.. supposedly! It however appears to convert to "yyyyddmm" format as long as the day is under 13!!???

Any help or suggestions please..

____________________________________________

Private Function cal_cmd(calEvent) As String

'Purpose: Convert event properties array into event command string

    ' convert date to yyyymmdd date code
    calEvent(0) = Application.WorksheetFunction.Text(calEvent(0), "yyyymmdd")
    ' set undefined image sizes to zero (29-Apr-2004: image size parameters now optional)
    'If Not IsNumeric(calEvent(6)) Then calEvent(6) = QUOTE & QUOTE
    'If Not IsNumeric(calEvent(7)) Then calEvent(7) = QUOTE & QUOTE

    cal_cmd = CMDBEG & calEvent(0) & DELIM
    For i = 1 To EVENTCOLUMNS - 1
        cal_cmd = cal_cmd & QuoteWord(calEvent(i)) & DELIM
    Next i
    cal_cmd = cal_cmd & QuoteWord(calEvent(EVENTCOLUMNS)) & CMDEND

End Function

__________________________________________________ ________
 
Old July 21st, 2005, 03:37 AM
Authorized User
 
Join Date: Jun 2003
Posts: 59
Thanks: 0
Thanked 0 Times in 0 Posts
Default

i think you need to use the VBA Format function, something like

Code:
calEvent(0) = Format$(calEvent(0), "yyyymmdd")
 
Old July 21st, 2005, 04:22 AM
Registered User
 
Join Date: Apr 2005
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to jonwitts
Default

Thanks for that!

It now works beautifully!!

:)





Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem in changing date format pannasn Crystal Reports 2 December 15th, 2007 12:26 AM
How to export the data to XML file format? mbshankar Pro VB 6 2 April 3rd, 2007 12:22 PM
export excel file ( format is changed ) urgent palanivel jayanthi ASP.NET 1.0 and 1.1 Professional 1 March 12th, 2007 05:32 PM
export excel file ( format is changed ) urgent palanivel jayanthi ASP.NET 1.0 and 1.1 Basics 1 March 12th, 2007 05:31 PM
How to Export an Image file to Excel Khurram Classic ASP Basics 0 June 18th, 2003 02:48 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.