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 February 10th, 2011, 08:34 AM
Authorized User
 
Join Date: Apr 2009
Posts: 23
Thanks: 1
Thanked 0 Times in 0 Posts
Default Date format help

Hi folks

I am trying this little piece of code with some problem: Active cell has a value e.g "16 Mar" and my objective is to convert the value to read as "2011-03-16"

Sub lc_date_format()
Dim a As String
Dim b As Date
b = ActiveCell
a = Format(b, "yyyy-mm-dd")
ActiveCell.ClearContents
ActiveCell.Value = a
End Sub

Problem is that when the cell is replaced by variable a, the result is still shown as "16 Mar". Any clue?

Thanks for your help.

SMI//
 
Old February 14th, 2011, 07:42 AM
Registered User
 
Join Date: Aug 2006
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

why does not work with an arraylist containing the months
possible this code snippet can get you started

Grtz,

Luc
www.scriptingit.be

Code:
Sub test()
Dim s As String
s = "21 Mar"
Dim l(12) As String
Dim d As Date
l(1) = "Jan"
l(2) = "Feb"
l(3) = "Mar"
Dim i As Integer
For i = 1 To 12
    If InStr(0, l(i), s) > 0 Then
        'MATCH
        ......................
    End If
    
Next

End Sub





Similar Threads
Thread Thread Starter Forum Replies Last Post
date format differs, need to force format somehow patricolsson ASP.NET 2.0 Basics 1 December 3rd, 2009 12:53 AM
Convert date to JDEdwards date format snufse ASP.NET 2.0 Basics 1 March 24th, 2009 08:54 AM
Convert British format date to American format? fyr PHP How-To 0 December 19th, 2007 03:17 PM
How to give Date format while entering date Subuana Beginning VB 6 4 March 17th, 2006 07:25 AM
date format differs, need to force format somehow patricolsson HTML Code Clinic 2 January 12th, 2006 05:55 AM





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