Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old July 21st, 2005, 03:11 AM
Registered User
 
Join Date: Apr 2005
Location: , , United Kingdom.
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

__________________________________________________ ________
Reply With Quote
  #2 (permalink)  
Old July 21st, 2005, 03:37 AM
Authorized User
 
Join Date: Jun 2003
Location: , , United Kingdom.
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")
Reply With Quote
  #3 (permalink)  
Old July 21st, 2005, 04:22 AM
Registered User
 
Join Date: Apr 2005
Location: , , United Kingdom.
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!!

:)
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 12:22 AM.


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