+ Reply to Thread
Results 1 to 6 of 6

Separating Column Data

  1. #1
    Registered User
    Join Date
    06-02-2014
    Location
    Oklahoma, USA
    MS-Off Ver
    2010
    Posts
    31

    Question Separating Column Data

    I am new to VBA but studying and learning and trying to 'practice' as much as I can.

    At work I have access to spreadsheets that I can copy and play with that have, in some cases, thousands of rows of data. One such spreadsheet I have been working with has Column A with a date and time in it:

    Please Login or Register  to view this content.
    The reason for this is that the spreadsheet is produced from the export of data from another program and it cannot be changed. What I have been trying to do is to take that column and use VBA code to split the date and time into their own column.

    I have thus been unsuccessful. Ive been googling as well with some tidbits here and there but nothing that seems all that efficient nor very specific to my need.

    There is duplicate data in all those rows, and some columns that I wont need once its all said and done. I have managed to write some code that gets rid of the duplicate data, extra columns, etc. I know, kids stuff to most, but I'm just trying to learn by doing at this point.

    I cant upload the spreadsheet unfortunately as it has work related data on it, but if you have any questions I will do my best to answer them, but any help on being able to split out the data would be really helpful.

    Thanks in advance.

  2. #2
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: Separating Column Data

    try:
    Please Login or Register  to view this content.
    let Source = #table({"Question","Thread", "User"},{{"Answered","Mark Solved", "Add Reputation"}}) in Source

    If I give you Power Query (Get & Transform Data) code, and you don't know what to do with it, then CLICK HERE

    Walking the tightrope between genius and eejit...

  3. #3
    Registered User
    Join Date
    06-02-2014
    Location
    Oklahoma, USA
    MS-Off Ver
    2010
    Posts
    31

    Re: Separating Column Data

    That almost worked perfectly.

    I failed to mention that there is a header row in the spreadsheet, but I can deal with that.

    The only thing that did not work was the date column. Im getting #VALUE! in the entire column. As I step through it its happening with the line:

    Please Login or Register  to view this content.
    I thought (just trying to see if I could spot the issue with observation) that it may be happening because in that line the date is formatted with 'yy' and the Number format is set up with 'yyyy', so I changed that, but it had no effect. Otherwise, everything else works perfectly.

    I appreciate your help and the time you took to write that code.

  4. #4
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: Separating Column Data

    Please post a sample workbook with some of your date data, formatted exactly as it is in your real worksheet.

  5. #5
    Registered User
    Join Date
    06-02-2014
    Location
    Oklahoma, USA
    MS-Off Ver
    2010
    Posts
    31

    Re: Separating Column Data

    I can provide much, as mentioned earlier, its work data and thus proprietary, but I have attached a portion of the spreadsheet that contains the date and time column.

    Alerts-Sample.xls

  6. #6
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: Separating Column Data

    Ah, US number format (this is why completing your profile with your location can be useful...)

    Change the numberformats, in red:
    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    06-02-2014
    Location
    Oklahoma, USA
    MS-Off Ver
    2010
    Posts
    31

    Re: Separating Column Data

    Ahhh yeah, sorry about that. When I stepped through the code I saw that it was evaluating 06/16/2014 as 16/06/2014 but it did not occur to me that could have been the issue.

    Just the same, thank you for the time you invested in helping me out. It is very much appreciated. I learned something I doubt I would have learned otherwise.

+ 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. Replies: 6
    Last Post: 01-16-2014, 01:45 PM
  2. Replies: 3
    Last Post: 05-10-2010, 12:14 PM
  3. Separating parts of data from downloaded column
    By WangDoodle in forum Excel General
    Replies: 6
    Last Post: 10-14-2008, 09:12 AM
  4. separating all data of one type into new column
    By hollow_dimm in forum Excel General
    Replies: 7
    Last Post: 07-16-2007, 12:14 PM
  5. Separating text and data in a column
    By Amber in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 04-04-2006, 06:45 PM

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