+ Reply to Thread
Results 1 to 10 of 10

F2 + ENTER to format cells

  1. #1
    Registered User
    Join Date
    12-12-2009
    Location
    Italy
    MS-Off Ver
    Excel 2003
    Posts
    15

    F2 + ENTER to format cells

    Hi!

    I have some imported data that Excel does not recognize as date or time so I have to edit each cell pressing F2 and the enter to "convert" the value.
    I have about 120.000 records and the macro takes long time to do the job.
    For i = 1 To 60000
    Cells(i, 1).Formula = Cells(i, 1).Formula
    Cells(i, 2).Formula = Cells(i, 2).Formula
    Next
    Is there a way to to this without blocking my pc?

    Thanks very much.

    Sergio.
    Attached Files Attached Files
    Last edited by sivanvega; 01-01-2010 at 10:29 PM.

  2. #2
    Forum Expert contaminated's Avatar
    Join Date
    05-07-2009
    Location
    Baku, Azerbaijan
    MS-Off Ver
    Excel 2013
    Posts
    1,430

    Re: F2 + ENTER to format cells

    Actually I'd do that using simple excel formulas lke DATEVALUE and TIMEVALUE
    Put in C2

    =DATEVALUE(A2)

    Put in D2

    =TIMEVALUE(B2)

    Copy both formulas down as far as u need. Than copy your output, select entire column A and B rght click > Paste Special > Value > OK
    Люди, питающие благие намерения, как раз и становятся чудовищами.

    Regards, ?Born in USSR?
    Vusal M Dadashev

    Baku, Azerbaijan

  3. #3
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: F2 + ENTER to format cells

    Another option would be...

    -- Enter 1 into C1
    -- Copy C1
    -- Highlight values in A2:B61751
    -- Edit -> Paste Special: Operation: Multiply
    In terms of a VBA routine - you could use Text to Columns, the above etc or use Evaluate eg:

    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    12-12-2009
    Location
    Italy
    MS-Off Ver
    Excel 2003
    Posts
    15

    Re: F2 + ENTER to format cells

    Thanks DonkeyOte, the VBA code is fast!!
    Could you explain me how it works? Is the first time I see the evaluate function.

    Sergio.

  5. #5
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: F2 + ENTER to format cells

    You could also use:
    Please Login or Register  to view this content.
    Remember what the dormouse said
    Feed your head

  6. #6
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: F2 + ENTER to format cells

    Quote Originally Posted by sivanvega
    Could you explain me how it works? Is the first time I see the evaluate function.
    As romperstomper has already proven - the Evaluate method is overkill in this instance so don't use it (apologies on my part).

    However, to answer your question... in this context easiest perhaps to think of Evaluate working along the lines of each value in the range being physically re-entered (akin to F2 - ENTER).

    Like F2/Enter when the value is re-entered XL interprets and formats accordingly ie the dates will be seen as dates (integer) and time values as time (decimal).

    Evaluate is a very powerful function in VBA - the VBE Help File on the method isn't great - there's a discussion on it's usage at OzGrid: http://www.ozgrid.com/forum/showthread.php?t=52372

    Evaluate is more commonly seen in conjunction with SUMPRODUCT however I often use it to avoid iteration - a tip I picked up from Bill Jelen's book "Excel Gurus Gone Wild"

  7. #7
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: F2 + ENTER to format cells

    Have you tried using Text to Columns, with a ~ delimiter and setting General as the format in the last screen?
    _
    ...How to Cross-post politely...
    ..Wrap code by selecting the code and clicking the # or read this. Thank you.

  8. #8
    Registered User
    Join Date
    12-12-2009
    Location
    Italy
    MS-Off Ver
    Excel 2003
    Posts
    15

    Re: F2 + ENTER to format cells

    Yes, but the solution is the VBA code when importing the file....this because will be used in different pc's with different date/time configurations.

    Thanks.

  9. #9
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: F2 + ENTER to format cells

    Though worth noting that for manual TtC you would need to process each column separately.

  10. #10
    Registered User
    Join Date
    07-17-2013
    Location
    Belgrade
    MS-Off Ver
    Excel 2007
    Posts
    1

    Re: F2 + ENTER to format cells

    @DonkeyOte


    Multiplying with 1 also worked for me! This is awesome, you helped me so much with this "stupid" problem

    Thanks!!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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