+ Reply to Thread
Results 1 to 6 of 6

Altering the existing macro to get date as numerical va;ue

  1. #1
    Registered User
    Join Date
    10-13-2010
    Location
    Miami, US
    MS-Off Ver
    Excel 2007
    Posts
    83

    Altering the existing macro to get date as numerical va;ue

    Hi everyone,

    I use a Macro (code attached) to flatten my dataset for dates (From vertical to Horizontal). Sample file is attached. However, in the resulting file dates appear as text and therefore, does not allow me to upload and use it with other softwares like SPSS for further analysis. Can someone please help me change the Macro code so that in the resultant file I get dates as numerical?

    Thank you

    Please Login or Register  to view this content.
    Attached Files Attached Files

  2. #2
    Forum Contributor
    Join Date
    02-15-2010
    Location
    Everett, WA
    MS-Off Ver
    All versions; most components
    Posts
    188

    Re: Altering the existing macro to get date as numerical va;ue

    Not sure what you mean by "dates as numerical". Your problem may be easily fixed by switching the cell formatting away from your current custom setting and to the date format you desire. In other words, I don't think the vba code is the problem, I think it's the cell "Number" formatting.

  3. #3
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,651

    Re: Altering the existing macro to get date as numerical va;ue

    Try this...

    Please Login or Register  to view this content.
    The Replace function coerces the text-dates into serial-dates.

  4. #4
    Registered User
    Join Date
    10-13-2010
    Location
    Miami, US
    MS-Off Ver
    Excel 2007
    Posts
    83

    Re: Altering the existing macro to get date as numerical va;ue

    Hi Gyclone,

    I want dates as numbers and not as text. The current problem is after using the Macro, my dates get converted into text. In this new attachment labelled as "Attendance after Macro" , I have used Macro to make it more clear. Column M, which is highlighted shows that the dates are not read as numbers now. Therefore, I cannot use them for any calculations because they are treated as string variable in SPSS.

    Regrading manual formatting: I tried using format option. It is feasible to use it with small number of cases. However, my problem with that is that I have huge dataset like 20,000 cases and 600 columns. It takes a lot of time to format every cell and if used together, the excel crashes every time.

    Thanks,
    Ajang
    Attached Files Attached Files

  5. #5
    Forum Contributor
    Join Date
    02-15-2010
    Location
    Everett, WA
    MS-Off Ver
    All versions; most components
    Posts
    188

    Re: Altering the existing macro to get date as numerical va;ue

    Hi ajang,

    I see from your spreadsheet what format you want, but, just so you'll understand my question, there are many, many ways that dates can be displayed as numbers (1/2/2013, 2013/1/2, 01/02/2013, 01-02-13, etc., etc.). In the future, you could save a step by including the actual format you want in your original post.

    As for how to accomplish it, you need to select the appropriate range and change the number format, which you can do via vba (you don't have to do it manually).

    Please Login or Register  to view this content.

  6. #6
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,834

    Re: Altering the existing macro to get date as numerical va;ue

    Try this
    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1