+ Reply to Thread
Results 1 to 15 of 15

separating time and date in two columns

  1. #1
    Forum Contributor
    Join Date
    05-05-2020
    Location
    Germany
    MS-Off Ver
    2013
    Posts
    100

    separating time and date in two columns

    Hey,

    How can I separate date and time in the following excel?

    The user should be able to insert the two columns "Date&Time" and "Power" any where in any worksheet and the button should separate date and time in 2 columns and copy power next to them in the same worksheet where data is.

    Thanks
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    10-11-2021
    Location
    Netherlands
    MS-Off Ver
    365
    Posts
    1,386

    Re: separating time and date in two columns

    Put this behind your commandbutton behind your Userform

    Please Login or Register  to view this content.

  3. #3
    Forum Contributor
    Join Date
    05-05-2020
    Location
    Germany
    MS-Off Ver
    2013
    Posts
    100

    Re: separating time and date in two columns

    Quote Originally Posted by JEC. View Post
    Put this behind your commandbutton behind your Userform

    Please Login or Register  to view this content.
    Could you explain this part:
    Please Login or Register  to view this content.
    what if the data is another worksheet than the button?

  4. #4
    Forum Expert
    Join Date
    10-11-2021
    Location
    Netherlands
    MS-Off Ver
    365
    Posts
    1,386

    Re: separating time and date in two columns

    That is where the user specifies the first cell of his data, which is been asked in you UF.
    When de button is in another sheet, you need a sheetreference too.

  5. #5
    Forum Contributor
    Join Date
    05-05-2020
    Location
    Germany
    MS-Off Ver
    2013
    Posts
    100

    Re: separating time and date in two columns

    I tried the code but didn't work.
    Attached Files Attached Files

  6. #6
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Cool Hey try this !


    According to your attachment an Excel basics VBA demonstration (v2) as a beginner starter
    to paste only in the Tabelle1 worksheet module :

    PHP Code: 
    Sub Demo1()
             
    Dim Rc As Range
             Set Rc 
    UsedRange.Find("Time stamp", , , 11):  If Rc Is Nothing Then Beep: Exit Sub
             Application
    .DisplayAlerts False
        With Range
    (RcRc.End(xlDown)).Resize(, 2).Columns
            
    .Item(2).Insert
            
    .Item(1).TextToColumns 1xlTextQualifierNone, , FalseFalseFalseTrueFalse
        End With
             Application
    .DisplayAlerts True
             Rc
    (2).Resize(, 2) = Split(Rc(2), "-")
             
    Set Rc Nothing
    End Sub 
    ► Do you like it ? ► So thanks to click on bottom left star icon ? Add Reputation ? !
    Last edited by Marc L; 09-17-2022 at 09:55 AM. Reason: optimization ...

  7. #7
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Re: separating time and date in two columns


    For 'any' worksheet then move the code to a standard module and add ActiveSheet. before UsedRange ...

  8. #8
    Valued Forum Contributor
    Join Date
    08-08-2022
    Location
    Buenos Aires
    MS-Off Ver
    Excel 2019
    Posts
    1,777

    Re: separating time and date in two columns

    Hello. Perhaps you can solve it without needing a userform like this:

    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by beyond Excel; 09-17-2022 at 10:17 AM.

  9. #9
    Forum Expert
    Join Date
    10-11-2021
    Location
    Netherlands
    MS-Off Ver
    365
    Posts
    1,386

    Re: separating time and date in two columns

    With sheet reference below.
    You can also delete your Textbox, where they have to put the first cell with data.

    Please Login or Register  to view this content.

  10. #10
    Forum Contributor
    Join Date
    05-05-2020
    Location
    Germany
    MS-Off Ver
    2013
    Posts
    100

    Re: Hey try this !

    Quote Originally Posted by Marc L View Post

    According to your attachment an Excel basics VBA demonstration (v2) as a beginner starter
    to paste only in the Tabelle1 worksheet module :

    PHP Code: 
    Sub Demo1()
             
    Dim Rc As Range
             Set Rc 
    UsedRange.Find("Time stamp", , , 11):  If Rc Is Nothing Then Beep: Exit Sub
             Application
    .DisplayAlerts False
        With Range
    (RcRc.End(xlDown)).Resize(, 2).Columns
            
    .Item(2).Insert
            
    .Item(1).TextToColumns 1xlTextQualifierNone, , FalseFalseFalseTrueFalse
        End With
             Application
    .DisplayAlerts True
             Rc
    (2).Resize(, 2) = Split(Rc(2), "-")
             
    Set Rc Nothing
    End Sub 
    ► Do you like it ? ► So thanks to click on bottom left star icon ? Add Reputation ? !
    Thanks alot! ^_^

  11. #11
    Forum Contributor
    Join Date
    05-05-2020
    Location
    Germany
    MS-Off Ver
    2013
    Posts
    100

    Re: Hey try this !

    Quote Originally Posted by Marc L View Post

    According to your attachment an Excel basics VBA demonstration (v2) as a beginner starter
    to paste only in the Tabelle1 worksheet module :

    PHP Code: 
    Sub Demo1()
             
    Dim Rc As Range
             Set Rc 
    UsedRange.Find("Time stamp", , , 11):  If Rc Is Nothing Then Beep: Exit Sub
             Application
    .DisplayAlerts False
        With Range
    (RcRc.End(xlDown)).Resize(, 2).Columns
            
    .Item(2).Insert
            
    .Item(1).TextToColumns 1xlTextQualifierNone, , FalseFalseFalseTrueFalse
        End With
             Application
    .DisplayAlerts True
             Rc
    (2).Resize(, 2) = Split(Rc(2), "-")
             
    Set Rc Nothing
    End Sub 
    ► Do you like it ? ► So thanks to click on bottom left star icon ? Add Reputation ? !
    What does
    Please Login or Register  to view this content.
    do? I mean , I know it findes the "time stamp" column but what is this ", , , 1, 1" part?

  12. #12
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,612

    Re: separating time and date in two columns

    Range.Find("Time stamp", , , 1, 1)

    For Range.Find(), there are nine parameters:
    What ,After, LookIn, LookAt, SearchOrder, SearchDirection, MatchCase, MatchByte & SearchFormat

    So:
    -What = "Time stamp"
    -After: (where to start), is not specified so it defaults to upper left cell of the range
    -LookIn: can have one of four options: 1) xlFormulas, 2) xlValues, 3) xlComments, 4) xlCommentsThreaded. It wasn't specified in the macro so it defauts to #1
    -LookAt: has two options: 1) xlWhole & 2) xlPart. The macro specifies option #1
    -SearchOrder: has two options: 1) xlByRows & 2) xlByColumns. Option #1 is specified.

    The rest of the paraments use the defaults. It could be written:

    Set Rc = UsedRange.Find(What:="Time stamp", LookAt:=xlWhole, SearchOrder:=xlByRows)
    Ben Van Johnson

  13. #13
    Valued Forum Contributor
    Join Date
    08-08-2022
    Location
    Buenos Aires
    MS-Off Ver
    Excel 2019
    Posts
    1,777

    Re: separating time and date in two columns

    Quote Originally Posted by (T_T) View Post
    ... How can I separate date and time in the following excel?
    Were you able to analyze the proposal of message #8?

  14. #14
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Arrow Re: Hey try this !


    Quote Originally Posted by (T_T) View Post
    I know it findes the "time stamp" column but what is this ", , , 1, 1" part?
    'Cause here I just follow the Range.Find VBA help, all is there, a must read !
    You can have the extended syntax like in post #12 just using the Macro Recorder ...
    Last edited by Marc L; 09-17-2022 at 07:15 PM.

  15. #15
    Forum Expert Crooza's Avatar
    Join Date
    10-19-2013
    Location
    Hunter Valley, Australia
    MS-Off Ver
    Excel 2003 /7/10
    Posts
    2,082

    Re: separating time and date in two columns

    Try this version attached to get you started if the above doesn't work for you
    Attached Files Attached Files
    Happy with my advice? Click on the * reputation button below

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Separating Time and Date in Cells.
    By ensbana in forum Excel General
    Replies: 2
    Last Post: 07-13-2020, 12:06 AM
  2. Separating date and hours using pivot table and showing time hourly
    By snkhan in forum Excel Charting & Pivots
    Replies: 2
    Last Post: 09-20-2018, 10:35 AM
  3. [SOLVED] Separating Time and Date for Timestamp
    By Grimace in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 03-16-2014, 08:37 PM
  4. Modifying and separating Date & Time from single cell
    By happyc in forum Excel Formulas & Functions
    Replies: 14
    Last Post: 05-08-2013, 07:26 AM
  5. Format cells problem with separating Date and Time
    By sajeel in forum Excel General
    Replies: 1
    Last Post: 02-09-2010, 02:34 PM
  6. separating date and time from one cell to two
    By bdebened in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 11-12-2009, 01:30 AM
  7. Separating date from a Date & Time stamp
    By JT in forum Excel General
    Replies: 3
    Last Post: 02-20-2005, 01:06 PM

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