Sort by date/time, copy, & paste special (transpose)

resinguy

New Member
Joined
Aug 30, 2017
Messages
2
Hi All,

I'm new to the forum and to the macro world. Here is what I'm trying to do:

  1. I have a datastream that consists of 23 datapoints/tag ID's that are logged on one minute intervals (see "Source Data")
  2. I would like to write a macro that select this data, sort it by date/time in ascending order, store numerical values as integers, copy the data, and transpose the data into a new workbook (see "Desired Format")
  3. I would like to be able to extract the source data into the new workbook without having to open the source data

Here are a few of the subtleties that are really throwing me for a loop:

  1. The range varies depending on when I download the source data
  2. Depending on when the source data is downloaded, the data tags/time stamps are not always the same
  3. I'm brand new to this
    Source Data
    Var Name
    Time String
    Var Value
    16
    8/17/2017 16:48
    11.68718
    17
    8/17/2017 16:48
    18
    8/17/2017 16:48
    5.160007
    19
    8/17/2017 16:48
    35.0317
    20
    8/17/2017 16:48
    64.51823
    21
    8/17/2017 16:48
    8.507451
    22
    8/17/2017 16:48
    237.8111
    23
    8/17/2017 16:48
    11.01189
    1
    8/17/2017 16:49
    63.87153
    2
    8/17/2017 16:49
    224.6817
    3
    8/17/2017 16:49
    26.2641
    4
    8/17/2017 16:49
    21.99421
    5
    8/17/2017 16:49
    2.101758
    6
    8/17/2017 16:49
    450.557
    7
    8/17/2017 16:49
    63.24147
    8
    8/17/2017 16:49
    26.43088
    9
    8/17/2017 16:49
    14.90093
    10
    8/17/2017 16:49
    20.85473
    11
    8/17/2017 16:49
    27.56299
    12
    8/17/2017 16:49
    16.36641
    13
    8/17/2017 16:49
    67.8
    14
    8/17/2017 16:49
    256.2681
    15
    8/17/2017 16:49
    964.3976
    16
    8/17/2017 16:49
    11.794
    17
    8/17/2017 16:49
    18
    8/17/2017 16:49
    5.131602
    19
    8/17/2017 16:49
    34.98778
    20
    8/17/2017 16:49
    64.67014
    21
    8/17/2017 16:49
    8.528718
    22
    8/17/2017 16:49
    239.2578
    23
    8/17/2017 16:49
    11.62359
    1
    8/17/2017 16:50
    64.09722
    2
    8/17/2017 16:50
    226.7506
    3
    8/17/2017 16:50
    26.2424
    4
    8/17/2017 16:50
    21.98591
    5
    8/17/2017 16:50
    2.081016
    6
    8/17/2017 16:50
    451.0634
    7
    8/17/2017 16:50
    63.22338
    8
    8/17/2017 16:50
    26.42253
    9
    8/17/2017 16:50
    14.89425
    10
    8/17/2017 16:50
    20.86643

    <tbody>
    </tbody>

    Desired Format
    Date/Time<o:p></o:p>

    1<o:p></o:p>

    2<o:p></o:p>

    3<o:p></o:p>

    4<o:p></o:p>

    5<o:p></o:p>

    6<o:p></o:p>

    7<o:p></o:p>

    8<o:p></o:p>

    9<o:p></o:p>

    10<o:p></o:p>

    11<o:p></o:p>

    12<o:p></o:p>

    13<o:p></o:p>

    14<o:p></o:p>

    15<o:p></o:p>

    16<o:p></o:p>

    17<o:p></o:p>

    18<o:p></o:p>

    19<o:p></o:p>

    20<o:p></o:p>

    21<o:p></o:p>

    22<o:p></o:p>

    23<o:p></o:p>

    8/17/2017 16:48<o:p></o:p>
    <o:p></o:p>
    <o:p></o:p>
    <o:p></o:p>
    <o:p></o:p>
    <o:p></o:p>
    <o:p></o:p>
    <o:p></o:p>
    <o:p></o:p>
    <o:p></o:p>
    <o:p></o:p>
    <o:p></o:p>
    <o:p></o:p>
    <o:p></o:p>
    <o:p></o:p>
    <o:p></o:p>

    12<o:p></o:p>

    0<o:p></o:p>

    5<o:p></o:p>

    35<o:p></o:p>

    65<o:p></o:p>

    9<o:p></o:p>

    238<o:p></o:p>

    11<o:p></o:p>

    8/17/2017 16:49<o:p></o:p>

    64<o:p></o:p>

    225<o:p></o:p>

    26<o:p></o:p>

    22<o:p></o:p>

    2<o:p></o:p>

    451<o:p></o:p>

    63<o:p></o:p>

    26<o:p></o:p>

    15<o:p></o:p>

    21<o:p></o:p>

    28<o:p></o:p>

    16<o:p></o:p>

    68<o:p></o:p>

    256<o:p></o:p>

    964<o:p></o:p>

    12<o:p></o:p>

    0<o:p></o:p>

    5<o:p></o:p>

    35<o:p></o:p>

    65<o:p></o:p>

    9<o:p></o:p>

    239<o:p></o:p>

    12<o:p></o:p>

    8/17/2017 16:50<o:p></o:p>

    64<o:p></o:p>

    227<o:p></o:p>

    26<o:p></o:p>

    22<o:p></o:p>

    2<o:p></o:p>

    451<o:p></o:p>

    63<o:p></o:p>

    26<o:p></o:p>

    15<o:p></o:p>

    21<o:p></o:p>

    28<o:p></o:p>

    16<o:p></o:p>

    68<o:p></o:p>

    255<o:p></o:p>

    966<o:p></o:p>

    12<o:p></o:p>

    0<o:p></o:p>

    5<o:p></o:p>

    35<o:p></o:p>

    65<o:p></o:p>

    9<o:p></o:p>

    239<o:p></o:p>

    11<o:p></o:p>

    <tbody>
    </tbody>

I have tried muddling around on Youtube and the internet, but I have to admit that this is not my sweet spot (geologist by education). Is what I'd like to do possible with a macro? Any guidance would be greatly appreciated.

Cheers,

Keith
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
Hi All,

I'm new to the forum and to the macro world. Here is what I'm trying to do:

  1. I have a datastream that consists of 23 datapoints/tag ID's that are logged on one minute intervals (see "Source Data")
  2. I would like to write a macro that select this data, sort it by date/time in ascending order, store numerical values as integers, copy the data, and transpose the data into a new workbook (see "Desired Format")
  3. I would like to be able to extract the source data into the new workbook without having to open the source data

Here are a few of the subtleties that are really throwing me for a loop:

  1. The range varies depending on when I download the source data
  2. Depending on when the source data is downloaded, the data tags/time stamps are not always the same
  3. I'm brand new to this
    Source Data
    Var NameTime StringVar Value
    168/17/2017 16:4811.68718
    178/17/2017 16:48
    188/17/2017 16:485.160007
    198/17/2017 16:4835.0317
    208/17/2017 16:4864.51823
    218/17/2017 16:488.507451
    228/17/2017 16:48237.8111
    238/17/2017 16:4811.01189
    18/17/2017 16:4963.87153
    28/17/2017 16:49224.6817
    38/17/2017 16:4926.2641
    48/17/2017 16:4921.99421
    58/17/2017 16:492.101758
    68/17/2017 16:49450.557
    78/17/2017 16:4963.24147
    88/17/2017 16:4926.43088
    98/17/2017 16:4914.90093
    108/17/2017 16:4920.85473
    118/17/2017 16:4927.56299
    128/17/2017 16:4916.36641
    138/17/2017 16:4967.8
    148/17/2017 16:49256.2681
    158/17/2017 16:49964.3976
    168/17/2017 16:4911.794
    178/17/2017 16:49
    188/17/2017 16:495.131602
    198/17/2017 16:4934.98778
    208/17/2017 16:4964.67014
    218/17/2017 16:498.528718
    228/17/2017 16:49239.2578
    238/17/2017 16:4911.62359
    18/17/2017 16:5064.09722
    28/17/2017 16:50226.7506
    38/17/2017 16:5026.2424
    48/17/2017 16:5021.98591
    58/17/2017 16:502.081016
    68/17/2017 16:50451.0634
    78/17/2017 16:5063.22338
    88/17/2017 16:5026.42253
    98/17/2017 16:5014.89425
    108/17/2017 16:5020.86643

    <tbody>
    </tbody>

    Desired Format
    Date/Time<o:p></o:p>
    1<o:p></o:p>
    2<o:p></o:p>
    3<o:p></o:p>
    4<o:p></o:p>
    5<o:p></o:p>
    6<o:p></o:p>
    7<o:p></o:p>
    8<o:p></o:p>
    9<o:p></o:p>
    10<o:p></o:p>
    11<o:p></o:p>
    12<o:p></o:p>
    13<o:p></o:p>
    14<o:p></o:p>
    15<o:p></o:p>
    16<o:p></o:p>
    17<o:p></o:p>
    18<o:p></o:p>
    19<o:p></o:p>
    20<o:p></o:p>
    21<o:p></o:p>
    22<o:p></o:p>
    23<o:p></o:p>
    8/17/2017 16:48<o:p></o:p>
    <o:p></o:p> <o:p></o:p> <o:p></o:p> <o:p></o:p> <o:p></o:p> <o:p></o:p> <o:p></o:p> <o:p></o:p> <o:p></o:p> <o:p></o:p> <o:p></o:p> <o:p></o:p> <o:p></o:p> <o:p></o:p> <o:p></o:p>
    12<o:p></o:p>
    0<o:p></o:p>
    5<o:p></o:p>
    35<o:p></o:p>
    65<o:p></o:p>
    9<o:p></o:p>
    238<o:p></o:p>
    11<o:p></o:p>
    8/17/2017 16:49<o:p></o:p>
    64<o:p></o:p>
    225<o:p></o:p>
    26<o:p></o:p>
    22<o:p></o:p>
    2<o:p></o:p>
    451<o:p></o:p>
    63<o:p></o:p>
    26<o:p></o:p>
    15<o:p></o:p>
    21<o:p></o:p>
    28<o:p></o:p>
    16<o:p></o:p>
    68<o:p></o:p>
    256<o:p></o:p>
    964<o:p></o:p>
    12<o:p></o:p>
    0<o:p></o:p>
    5<o:p></o:p>
    35<o:p></o:p>
    65<o:p></o:p>
    9<o:p></o:p>
    239<o:p></o:p>
    12<o:p></o:p>
    8/17/2017 16:50<o:p></o:p>
    64<o:p></o:p>
    227<o:p></o:p>
    26<o:p></o:p>
    22<o:p></o:p>
    2<o:p></o:p>
    451<o:p></o:p>
    63<o:p></o:p>
    26<o:p></o:p>
    15<o:p></o:p>
    21<o:p></o:p>
    28<o:p></o:p>
    16<o:p></o:p>
    68<o:p></o:p>
    255<o:p></o:p>
    966<o:p></o:p>
    12<o:p></o:p>
    0<o:p></o:p>
    5<o:p></o:p>
    35<o:p></o:p>
    65<o:p></o:p>
    9<o:p></o:p>
    239<o:p></o:p>
    11<o:p></o:p>

    <tbody>
    </tbody>

I have tried muddling around on Youtube and the internet, but I have to admit that this is not my sweet spot (geologist by education). Is what I'd like to do possible with a macro? Any guidance would be greatly appreciated.

Cheers,

Keith

not good with macros but I think you can do this with the use of a pivot table:

where:
Rows - Time String
Columns - Var Name
Values - Var Value, format to Number without decimal points
 
Upvote 0

Forum statistics

Threads
1,215,050
Messages
6,122,868
Members
449,097
Latest member
dbomb1414

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top