+ Reply to Thread
Results 1 to 7 of 7

Keeping Date Format in String

Hybrid View

freybe06 Keeping Date Format in String 12-05-2012, 12:10 PM
Norie Re: Keeping Date Format in... 12-05-2012, 12:14 PM
freybe06 Re: Keeping Date Format in... 12-05-2012, 12:23 PM
Norie Re: Keeping Date Format in... 12-05-2012, 12:30 PM
freybe06 Re: Keeping Date Format in... 12-05-2012, 12:38 PM
freybe06 Re: Keeping Date Format in... 12-05-2012, 12:36 PM
Norie Re: Keeping Date Format in... 12-05-2012, 12:39 PM
  1. #1
    Forum Contributor
    Join Date
    06-17-2010
    Location
    Philadelphia, PA
    MS-Off Ver
    Excel 2010
    Posts
    228

    Keeping Date Format in String

    Hello,

    I've tried looking around for someone that posted the exact question I'm looking to have answered and I couldn't find anything so I apologize if I'm duplicating.

    Essentially, what I'm trying to do, is change a spreadsheet in xls format to csv format. As part of that, I have a formula that combines all the columns with a ";" separating the information. Here is the formula:

    ActiveCell.FormulaR1C1 = "=RC[-11]&"";""&RC[-10]&"";""&RC[-9]&"";""&RC[-8]&"";""&RC[-7]&"";""&FORMAT(RC[-6],""Short Date"")&"";""&FORMAT(RC[-5],""Short Date"")&"";""&RC[-4]&"";""&RC[-3]&"";""&RC[-2]&"";""&RC[-1]"
    I believe I'm getting an error because of the 2 columns that I need as "short date". When I originally just had that part of the formula like the rest of it, it would change the date in to a number.

    If someone could please let me know what tweak I need to make to the formula to keep the formatting of each column, I'd appreciate it.

    Please let me know if you need more information.

    Thanks!

    Jeff

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,645

    Re: Keeping Date Format in String

    Jeff

    There's no FORMAT worksheet function, the equivalent worksheet function to VBA's Format is TEXT.
    If posting code please use code tags, see here.

  3. #3
    Forum Contributor
    Join Date
    06-17-2010
    Location
    Philadelphia, PA
    MS-Off Ver
    Excel 2010
    Posts
    228

    Re: Keeping Date Format in String

    Norie,

    This formula is in VBA. I'm creating a macro and the formula is part of the process.

    Thanks

  4. #4
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,645

    Re: Keeping Date Format in String

    I know the formula is in VBA but you can't use VBA in worksheet formulas.

    If I run the code I get a !NAME# error because FORMAT isn't recognised.

  5. #5
    Forum Contributor
    Join Date
    06-17-2010
    Location
    Philadelphia, PA
    MS-Off Ver
    Excel 2010
    Posts
    228

    Re: Keeping Date Format in String

    Sorry - I should've tried before I asked... That worked perfectly.

    Thanks again Norie!

  6. #6
    Forum Contributor
    Join Date
    06-17-2010
    Location
    Philadelphia, PA
    MS-Off Ver
    Excel 2010
    Posts
    228

    Re: Keeping Date Format in String

    I apoligize - I see what you mean. I changed the formula to read:

    ActiveCell.FormulaR1C1 = "=RC[-11]&"";""&RC[-10]&"";""&RC[-9]&"";""&RC[-8]&"";""&RC[-7]&"";""&TEXT(RC[-6],""Short Date"")&"";""&TEXT(RC[-5],""Short Date"")&"";""&RC[-4]&"";""&RC[-3]&"";""&RC[-2]&"";""&RC[-1]"
    ...and now "7/1/2012" turned in to "00ort 1at2012". Should I change "Short Date" to "mm/dd/yyyy"?

    Thanks

  7. #7
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,645

    Re: Keeping Date Format in String

    Yes, you'll need to change Short Date because Excel won't recognise that either.

+ 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