Wrox Programmer Forums
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 October 31st, 2005, 05:26 AM
Authorized User
Join Date: Sep 2003
Posts: 34
Thanks: 0
Thanked 0 Times in 0 Posts
Default Date Formatting

Hi all,

I have written a vba macro that takes dates from two seperate workbooks and pastes them into a new workbook.

the 2 source workbooks both have the date format as dd/mm/yyyy, and the workbook they are being copied into also has that format set for the date cells.

however, when the dates are transferred, they display as mm/dd/yyyy, even though the format of the cell is dd/mm/yyyy.

Any ideas on what I am doing wrong?



Visit my site: http://www.drybonesuk.com
Visit my site: http://www.drybonesuk.com
Old October 31st, 2005, 10:00 AM
Registered User
Join Date: Oct 2005
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts

Hi Patrick try the following code,
Sub test()
Dim dteDate As Date
dteDate = Now
Range("A1").Value = Format(dteDate, dd / mm / yyyy)
End Sub
You can play around with the format section to make it appear in pretty much any combination you like

Hope this helps

Old October 31st, 2005, 12:03 PM
Authorized User
Join Date: Sep 2003
Posts: 34
Thanks: 0
Thanked 0 Times in 0 Posts

thanks very much, that worked a treat!

Visit my site: http://www.drybonesuk.com

Similar Threads
Thread Thread Starter Forum Replies Last Post
Date Formatting MargateFan XSLT 3 August 30th, 2006 07:42 AM
Date Formatting, need some assistance groovedrm Access VBA 2 June 16th, 2006 07:23 AM
Date formatting jroxit Classic ASP Basics 3 February 26th, 2006 10:07 PM
formatting date time Adam H-W Classic ASP Basics 4 September 29th, 2004 03:35 AM
Formatting to a Date trekmp ADO.NET 2 March 16th, 2004 01:37 PM

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