+ Reply to Thread
Results 1 to 79 of 79

How to split data in one column into two

  1. #1
    Registered User
    Join Date
    07-21-2017
    Location
    Toronto, Canada
    MS-Off Ver
    MS Excel 2010
    Posts
    54

    How to split data in one column into two

    Hi Excel Forum

    So it's been a long time since I've used Excel and I have a column that begins with Yes and No values followed by additional text, e.g. (Yes - No data). What I want to do is separate the yes/no values in one column and the additional text into another. I was able to insert a new column and paste the previous column's information into it as a safe guard and make that the new comments column. So my question is how do I remove text following either yes or no from the first column? Thank you.

  2. #2
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,929

    Re: How to split data in one column into two

    Hi, welcome to the forum

    1st, is both Yes and No in the same cell together?

    If not, then maybe something like...
    =mid(A1,if(left(A1,3)'"Yes",4,3),99)
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  3. #3
    Valued Forum Contributor
    Join Date
    07-10-2017
    Location
    Toronto, Ontario
    MS-Off Ver
    Excel 2013
    Posts
    430

    Re: How to split data in one column into two

    You can use this as an example for a cell "A1". This will return either "Yes" or "No" in whichever cell you enter it in. This will work regardless of what follows Yes/No, as long as there is nothing in front of it.
    =IF((LEFT(A1,3)="YES"),LEFT(A1,3),LEFT(A1,2))

    Edit: I see I was beaten to it
    Last edited by danielexcelvba; 07-21-2017 at 01:58 PM.

  4. #4
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,929

    Re: How to split data in one column into two

    Quote Originally Posted by danielexcelvba View Post
    You can use this as an example for a cell "A1". This will return either "Yes" or "No" in whichever cell you enter it in. This will work regardless of what follows Yes/No, as long as there is nothing in front of it.
    =IF((LEFT(A1,3)="YES"),LEFT(A1,3),LEFT(A1,2))

    Edit: I see I was beaten to it
    Mine pulls the remainder of the text, yours will pull the yes/no

    Could be shortened to this...
    =if(left(A3,3)="YES","no")

  5. #5
    Registered User
    Join Date
    07-21-2017
    Location
    Toronto, Canada
    MS-Off Ver
    MS Excel 2010
    Posts
    54

    Re: How to split data in one column into two

    Hi everyone, thank you for the replies, i look forward to trying them out. But here's an embarrassing question. To input those formulas, do I click on the top of the cell (e.g. "R1"), right click and select format cells? thank you all

  6. #6
    Valued Forum Contributor
    Join Date
    07-10-2017
    Location
    Toronto, Ontario
    MS-Off Ver
    Excel 2013
    Posts
    430

    Re: How to split data in one column into two

    Oh sorry I thought that's what they were asking.
    You would enter this into the first cell of the column you want the data to be in, make sure the reference is set to the column the data is currently in, and then drag it down for however many rows you have data.

  7. #7
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,929

    Re: How to split data in one column into two

    Not an embarrassing question at all - if you dont know excel, that that is a perfectly good question

    You would enter daniel's suggestion where you want the YES/NO to show, and my suggestion where you want the rest to show. Then just copy both down as needed

  8. #8
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,929

    Re: How to split data in one column into two

    Also, we both used A1 as the reference to where your text is, adjust that as needed

  9. #9
    Valued Forum Contributor
    Join Date
    07-10-2017
    Location
    Toronto, Ontario
    MS-Off Ver
    Excel 2013
    Posts
    430

    Re: How to split data in one column into two

    =mid(A1,if(left(A1,3)'"Yes",4,3),99)
    Don't want to question you, but is it possible that the single quote is a typo and is supposed to be an "="? The formula doesn't work for me otherwise.
    This is what I entered:
    =MID(A1,IF(LEFT(A1,3)="Yes",4,3),99)
    Last edited by danielexcelvba; 07-21-2017 at 02:45 PM.

  10. #10
    Registered User
    Join Date
    07-21-2017
    Location
    Toronto, Canada
    MS-Off Ver
    MS Excel 2010
    Posts
    54

    Re: How to split data in one column into two

    Hey guys,

    So the first formula:
    Please Login or Register  to view this content.
    I got a message box saying Circular Reference Warning and changed "No" to 0.

    I got the same message with:
    Please Login or Register  to view this content.
    Then I tried:
    Please Login or Register  to view this content.
    And I got The name that you have entered is not valid and lists a bunch of reasons why

    Does anyone know how to fix these errors??

  11. #11
    Valued Forum Contributor
    Join Date
    07-10-2017
    Location
    Toronto, Ontario
    MS-Off Ver
    Excel 2013
    Posts
    430

    Re: How to split data in one column into two

    Which cell are you trying to enter these formulas in? Are you trying to enter this in cell R2? The first one definitely works for me (returns yes or no).
    For the last one, try:
    =MID(R2,IF(LEFT(R2,3)="Yes",4,3),99)

  12. #12
    Valued Forum Contributor
    Join Date
    07-10-2017
    Location
    Toronto, Ontario
    MS-Off Ver
    Excel 2013
    Posts
    430

    Re: How to split data in one column into two

    I'm guessing you entered it into "R2" as I can't think of any other reason you'd get a circular reference. Formulas cannot reference the cells they are placed in, so you're going to have to enter this formula into a different blank column (e.g. "S2"). If you really want your data to be in column "R", you can then copy column "S" and paste the values into "R".

  13. #13
    Registered User
    Join Date
    07-21-2017
    Location
    Toronto, Canada
    MS-Off Ver
    MS Excel 2010
    Posts
    54

    Re: How to split data in one column into two

    I'm trying to enter in R2:

    I just tried:
    Please Login or Register  to view this content.
    And I get the same Circular Reference error. "R2" in the formula is highlight blue and I think excel thinks that means "radians" but im just trying to select the cell in the R column. Thank you
    Last edited by deleter; 07-21-2017 at 03:06 PM.

  14. #14
    Valued Forum Contributor
    Join Date
    07-10-2017
    Location
    Toronto, Ontario
    MS-Off Ver
    Excel 2013
    Posts
    430

    Re: How to split data in one column into two

    The blue highlight means it is interpreting it as a cell. You probably posted it at the same time I posted my explanation (see above) so you didn't notice it. You're not going to be able to post this in "R2".

  15. #15
    Registered User
    Join Date
    07-21-2017
    Location
    Toronto, Canada
    MS-Off Ver
    MS Excel 2010
    Posts
    54

    Re: How to split data in one column into two

    Some of the cells in the column are blank

    So I tried:
    Please Login or Register  to view this content.
    And it changes everything to Yes including cells with No

  16. #16
    Valued Forum Contributor
    Join Date
    07-10-2017
    Location
    Toronto, Ontario
    MS-Off Ver
    Excel 2013
    Posts
    430

    Re: How to split data in one column into two

    Would it be possible for you to attach a sample workbook (or at least a screenshot of one) showing a subset of your data (with personal info changed/deleted), and showing what results you would like to achieve (you can enter it manually for the example)

  17. #17
    Registered User
    Join Date
    07-21-2017
    Location
    Toronto, Canada
    MS-Off Ver
    MS Excel 2010
    Posts
    54

    Re: How to split data in one column into two

    yesandno.PNG

    Here you are sir. As mentioned I inserted another column which will be the 'comments' column and pasted everything into it. for example S11 should say "(Jan 18/17)" minus the "yes" before it.

  18. #18
    Valued Forum Contributor
    Join Date
    07-10-2017
    Location
    Toronto, Ontario
    MS-Off Ver
    Excel 2013
    Posts
    430

    Re: How to split data in one column into two

    So just to clarify, your total data (Yes/No + text) is in column R, you want the text in column S, and the "Yes/No" somewhere else (column T maybe)?

  19. #19
    Registered User
    Join Date
    07-21-2017
    Location
    Toronto, Canada
    MS-Off Ver
    MS Excel 2010
    Posts
    54

    Re: How to split data in one column into two

    Exactly!

    Sorry if I wasn't clear in my explanation

  20. #20
    Valued Forum Contributor
    Join Date
    07-10-2017
    Location
    Toronto, Ontario
    MS-Off Ver
    Excel 2013
    Posts
    430

    Re: How to split data in one column into two

    I'm uploading a workbook showing the solution to the sample. I just entered
    =MID(R2,IF(LEFT(R2,3)="Yes",4,3),99)
    into "S2", and
    =IF((LEFT(R2,3)="YES"),LEFT(R2,3),LEFT(R2,2))
    into "T2", and the dragged the formulas down.
    Attached Files Attached Files

  21. #21
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,929

    Re: How to split data in one column into two

    Quote Originally Posted by danielexcelvba View Post
    Don't want to question you, but is it possible that the single quote is a typo and is supposed to be an "="? The formula doesn't work for me otherwise.
    This is what I entered:
    =MID(A1,IF(LEFT(A1,3)="Yes",4,3),99)
    Yes you are correct, that was a typo (and question all you like, we all make mistakes)

  22. #22
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,929

    Re: How to split data in one column into two

    Quote Originally Posted by danielexcelvba View Post
    I'm uploading a workbook showing the solution to the sample. I just entered
    =MID(R2,IF(LEFT(R2,3)="Yes",4,3),99)
    into "S2", and
    =IF((LEFT(R2,3)="YES"),LEFT(R2,3),LEFT(R2,2))
    into "T2", and the dragged the formulas down.
    Your sample file looks good to me

  23. #23
    Registered User
    Join Date
    07-21-2017
    Location
    Toronto, Canada
    MS-Off Ver
    MS Excel 2010
    Posts
    54

    Re: How to split data in one column into two

    Good morning everyone

    Thank you guys. And thanks Daniel, your sample worked perfectly!

  24. #24
    Registered User
    Join Date
    07-21-2017
    Location
    Toronto, Canada
    MS-Off Ver
    MS Excel 2010
    Posts
    54

    Re: How to split data in one column into two

    Before we wrap this up just a quick question

    dates.PNG

    I have a similar issue here. There are three date columns (N, O, P). I was thinking of using what Daniel has provided and playing around with this to get one column in a specific date format and the other column to be a comment column. However "ongoing" should be set to plus 10 years (e.g. 2013-04-01 in column N, ongoing = 2023-04-01 in column O). Does anyone have any suggestions? Thank you!

  25. #25
    Valued Forum Contributor
    Join Date
    07-10-2017
    Location
    Toronto, Ontario
    MS-Off Ver
    Excel 2013
    Posts
    430

    Re: How to split data in one column into two

    Sorry I'm not really sure what you're asking. It would probably be helpful if you showed what you would like the solution to look like.

  26. #26
    Registered User
    Join Date
    07-21-2017
    Location
    Toronto, Canada
    MS-Off Ver
    MS Excel 2010
    Posts
    54

    Re: How to split data in one column into two

    Quote Originally Posted by danielexcelvba View Post
    Sorry I'm not really sure what you're asking. It would probably be helpful if you showed what you would like the solution to look like.
    I'm sorry. Let me try again. In the O column, I was wondering is there a way to change ongoing to 2023-04-01 (because in column N, the date is 2013-04-01) since I was told 'ongoing' is N's date plus ten years. Thank you.

  27. #27
    Valued Forum Contributor
    Join Date
    07-10-2017
    Location
    Toronto, Ontario
    MS-Off Ver
    Excel 2013
    Posts
    430

    Re: How to split data in one column into two

    Ah I see. If you can format column "N" as a date that shouldn't be too hard. However, once again, you'd have to put the new dates into a column that isn't "N" or "O" to avoid a circular reference warning. You could try something like this:
    =IF(O1="ongoing",(DATE((YEAR(N1)+10),MONTH(N1),DAY(N1))),N1)
    This will add 10 years onto the date if column "O" contains "ongoing", and will otherwise just copy the date from column "N". I don't think it will work unless you first format as a date though

  28. #28
    Registered User
    Join Date
    07-21-2017
    Location
    Toronto, Canada
    MS-Off Ver
    MS Excel 2010
    Posts
    54

    Re: How to split data in one column into two

    Great. Thank you. Now to split column N, I know I'm supposed to do something like this

    Please Login or Register  to view this content.
    as this is how we split the yes/no field.

    Except, instead of yes or no, N has date values that aren't in a consistent format (e.g. 2013-02-21, October 21, 2012, etc.). I tried going Format Cells > Date > 03/14/01 but that didn't do anything. Do you guys know how to do this? If not I don't mind manually entering the dates in the correct format however before I did that I was just curious on what you guys think. Thanks again.

  29. #29
    Valued Forum Contributor
    Join Date
    07-10-2017
    Location
    Toronto, Ontario
    MS-Off Ver
    Excel 2013
    Posts
    430

    Re: How to split data in one column into two

    I think having text after your date is what is preventing you from formatting it correctly. Someone on here might know a way to fix it, but I personally don't know how you would format it without erasing everything after the date.

  30. #30
    Registered User
    Join Date
    07-21-2017
    Location
    Toronto, Canada
    MS-Off Ver
    MS Excel 2010
    Posts
    54

    Re: How to split data in one column into two

    Ok thank you.

  31. #31
    Valued Forum Contributor
    Join Date
    07-10-2017
    Location
    Toronto, Ontario
    MS-Off Ver
    Excel 2013
    Posts
    430

    Re: How to split data in one column into two

    Here's one idea I had. I wrote a quick Macro (vba code) that will work for the date formats YYYY-MM-DD, Month DD, YYYY and DD/MM/YYYY. As long as your cells in column "N" start with the date and it is in one of these formats, the code will work. I've attached an example workbook so you can see if it's what you're looking for (click the button to run it).
    If you're not comfortable using macros, hopefully someone here can help you out with a formula!

    Edit: this will also work for Month(abbreviation) DD, YYYY Month(abbreviation), DD, YYYY and Month, DD, YYYY
    Attached Files Attached Files
    Last edited by danielexcelvba; 07-24-2017 at 12:50 PM.

  32. #32
    Registered User
    Join Date
    07-21-2017
    Location
    Toronto, Canada
    MS-Off Ver
    MS Excel 2010
    Posts
    54

    Re: How to split data in one column into two

    Hi

    I appreciate that. I downloaded your sample and when I hit "Click me" I got a message saying Cannot run macro[name]. The macro may not be available in this workbook or all macros may be disabled

  33. #33
    Valued Forum Contributor
    Join Date
    07-10-2017
    Location
    Toronto, Ontario
    MS-Off Ver
    Excel 2013
    Posts
    430

    Re: How to split data in one column into two

    You probably have macros disabled then (that's the default setting). There should be an option to enable them when you open the workbook but if not, you can go to File > Options > Trust center > Trust Center Settings > Macro Settings > Enable All Macros
    Last edited by danielexcelvba; 07-24-2017 at 01:11 PM.

  34. #34
    Registered User
    Join Date
    07-21-2017
    Location
    Toronto, Canada
    MS-Off Ver
    MS Excel 2010
    Posts
    54

    Re: How to split data in one column into two

    Thats exactly it. Thank you. It works now.

  35. #35
    Valued Forum Contributor
    Join Date
    07-10-2017
    Location
    Toronto, Ontario
    MS-Off Ver
    Excel 2013
    Posts
    430

    Re: How to split data in one column into two

    Awesome! Let me know if it works on your actual workbook (or if you don't know how to run in on that workbook), or if you have dates in other formats that aren't being recognized. I slightly edited the code to include a few more date formats if you want to try the new one
    Please Login or Register  to view this content.
    Just note that running a macro cannot be undone, so if it screws up your data, simply close and reopen the workbook without saving

  36. #36
    Registered User
    Join Date
    07-21-2017
    Location
    Toronto, Canada
    MS-Off Ver
    MS Excel 2010
    Posts
    54

    Re: How to split data in one column into two

    Hey Daniel, how did you add the Click me button?

    Also I plan on putting that button on X2 but still use N and O columns.
    Last edited by deleter; 07-24-2017 at 02:30 PM.

  37. #37
    Valued Forum Contributor
    Join Date
    07-10-2017
    Location
    Toronto, Ontario
    MS-Off Ver
    Excel 2013
    Posts
    430

    Re: How to split data in one column into two

    You don't actually need a button to run the code, I just added one for simplicity. If you simply want to run the code, you can press Alt + F11 once inside your workbook to open the vba window, then go to insert > module and paste the code in. Once the code is in there, press the green arrow at the top or "F5" to run the code.

    If you prefer the button, this will give you an overview of how to add one (you still will need to paste the code into a new module first).
    https://support.office.com/en-us/art...rs=en-US&ad=US

    Also, the location of the button will not matter.

  38. #38
    Registered User
    Join Date
    07-21-2017
    Location
    Toronto, Canada
    MS-Off Ver
    MS Excel 2010
    Posts
    54

    Re: How to split data in one column into two

    When I tried running it I got an error saying

    Run-time error '9'

    Subscript out of range


    Please Login or Register  to view this content.
    Cells(i, 18).Value = larray(0) is highlighted yellow

    I tried changing the 18 to 1550 (number of current records) but that didn't do anything.

  39. #39
    Valued Forum Contributor
    Join Date
    07-10-2017
    Location
    Toronto, Ontario
    MS-Off Ver
    Excel 2013
    Posts
    430

    Re: How to split data in one column into two

    I have no idea how that would happen I'm going to start a new post in the vba forum to see if anyone can figure it out.
    In the meantime, you could paste values into the sample workbook and then paste the filtered answers back into your workbook.

  40. #40
    Registered User
    Join Date
    07-21-2017
    Location
    Toronto, Canada
    MS-Off Ver
    MS Excel 2010
    Posts
    54

    Re: How to split data in one column into two

    Thank you!

  41. #41
    Valued Forum Contributor
    Join Date
    07-10-2017
    Location
    Toronto, Ontario
    MS-Off Ver
    Excel 2013
    Posts
    430

    Re: How to split data in one column into two

    Ah never mind I think I may have figured it out. Do you have any blank cells in your workbook? That is likely what is throwing it off

  42. #42
    Registered User
    Join Date
    07-21-2017
    Location
    Toronto, Canada
    MS-Off Ver
    MS Excel 2010
    Posts
    54

    Re: How to split data in one column into two

    Quote Originally Posted by danielexcelvba View Post
    Ah never mind I think I may have figured it out. Do you have any blank cells in your workbook? That is likely what is throwing it off
    Yes, some of the cells are indeed blank

  43. #43
    Valued Forum Contributor
    Join Date
    07-10-2017
    Location
    Toronto, Ontario
    MS-Off Ver
    Excel 2013
    Posts
    430

    Re: How to split data in one column into two

    One small change. It should work now (I hope)
    Please Login or Register  to view this content.

  44. #44
    Registered User
    Join Date
    07-21-2017
    Location
    Toronto, Canada
    MS-Off Ver
    MS Excel 2010
    Posts
    54

    Re: How to split data in one column into two

    I tried running that and I get an error saying Run-time error '13' Mismatch Type and this is what the Final Date column shows

    dates3.PNG

    As you can see, it kind of works as two new dates are displayed.

    Once again, I appreciate all your hard work in trying to help me get this thing going.

  45. #45
    Valued Forum Contributor
    Join Date
    07-10-2017
    Location
    Toronto, Ontario
    MS-Off Ver
    Excel 2013
    Posts
    430

    Re: How to split data in one column into two

    Ah yes I forgot to edit the rest of it. You can try this, and if it still gives an error please let me know which part was highlighted again.
    Please Login or Register  to view this content.

  46. #46
    Valued Forum Contributor
    Join Date
    07-10-2017
    Location
    Toronto, Ontario
    MS-Off Ver
    Excel 2013
    Posts
    430

    Re: How to split data in one column into two

    Looking at your results, for the strange text in column "P", did the corresponding cells in column "N" start with a date?

  47. #47
    Registered User
    Join Date
    07-21-2017
    Location
    Toronto, Canada
    MS-Off Ver
    MS Excel 2010
    Posts
    54

    Re: How to split data in one column into two

    For the most part yes, except I found a few records that say something with a date (e.g. DO NOT USE - VACCINE REQUIRED 2014-06-16 new non-standard sent to CS 2016-04-08 - KMJ)

  48. #48
    Registered User
    Join Date
    07-21-2017
    Location
    Toronto, Canada
    MS-Off Ver
    MS Excel 2010
    Posts
    54

    Re: How to split data in one column into two

    Quote Originally Posted by danielexcelvba View Post
    Looking at your results, for the strange text in column "P", did the corresponding cells in column "N" start with a date?
    odddates.PNG

    Here's a few of the odd results

  49. #49
    Registered User
    Join Date
    07-21-2017
    Location
    Toronto, Canada
    MS-Off Ver
    MS Excel 2010
    Posts
    54

    Re: How to split data in one column into two

    gooddates.PNG

    But for the most part the dates are on point

  50. #50
    Valued Forum Contributor
    Join Date
    07-10-2017
    Location
    Toronto, Ontario
    MS-Off Ver
    Excel 2013
    Posts
    430

    Re: How to split data in one column into two

    Ah yes the code doesn't handle dates in the Month DD/YYYY format. I can try to edit it so it will though.
    But for "D on Dec 1" the cells in column "N" were blank?

  51. #51
    Registered User
    Join Date
    07-21-2017
    Location
    Toronto, Canada
    MS-Off Ver
    MS Excel 2010
    Posts
    54

    Re: How to split data in one column into two

    I believe so because I haven't entered anything in there. If it helps I can just manually edit those odd records. There aren't many.

  52. #52
    Valued Forum Contributor
    Join Date
    07-10-2017
    Location
    Toronto, Ontario
    MS-Off Ver
    Excel 2013
    Posts
    430

    Re: How to split data in one column into two

    Ok so this should resolve the issue of the other date formats, and it not recognizing "ongoing" when it is upper case or part of a longer text. Hopefully it will also resolve the weird texts. Let me know if it works!
    Please Login or Register  to view this content.

  53. #53
    Registered User
    Join Date
    07-21-2017
    Location
    Toronto, Canada
    MS-Off Ver
    MS Excel 2010
    Posts
    54

    Re: How to split data in one column into two

    Ok and just to make sure I'm placing this code in the right spot, Once i hit ALT + F11, under VBAProject([project name]) > Microsoft Excel Objects > Sheet1 ([project name]) > This workbook is what I see. Do I paste that into sheet one or this workbook? Thank you.

  54. #54
    Valued Forum Contributor
    Join Date
    07-10-2017
    Location
    Toronto, Ontario
    MS-Off Ver
    Excel 2013
    Posts
    430

    Re: How to split data in one column into two

    Sorry before you try that I had to edit something again (I keep forgetting).
    Please Login or Register  to view this content.
    And you can paste it into workbook, or create a module and paste it there

  55. #55
    Registered User
    Join Date
    07-21-2017
    Location
    Toronto, Canada
    MS-Off Ver
    MS Excel 2010
    Posts
    54

    Re: How to split data in one column into two

    Okay and after it's pasted. Do I simply hit the green arrow? Or the stop button and THEN the green arrow? I know noob question but

  56. #56
    Valued Forum Contributor
    Join Date
    07-10-2017
    Location
    Toronto, Ontario
    MS-Off Ver
    Excel 2013
    Posts
    430

    Re: How to split data in one column into two

    Just the green arrow should work

  57. #57
    Registered User
    Join Date
    07-21-2017
    Location
    Toronto, Canada
    MS-Off Ver
    MS Excel 2010
    Posts
    54

    Re: How to split data in one column into two

    Daniel. Thank you very much this worked. However I should note something strange happened. The 3 yes/no columns we discussed earlier in this thread (original, comment, yes/no), suddenly there is no data in all three columns R, S, T and the Yes/No column got shifted over to U with no data as well. I don't mind re doing what we already discussed. However I just felt it might be worth mentioning as I hope these two splits can coexist in the same spreadsheet. Thank you!

  58. #58
    Valued Forum Contributor
    Join Date
    07-10-2017
    Location
    Toronto, Ontario
    MS-Off Ver
    Excel 2013
    Posts
    430

    Re: How to split data in one column into two

    Oh I didn't realize these two questions were about the same worksheet, I thought those columns would be blank.
    I used those columns as "Helper Columns" for the code (used to store intermediate values), and then deleted them so that you wouldn't be left with random values in them. If you tell me the names of a few blank columns in your workbook I could change it to those instead (e.g. X/Y/Z maybe?)

  59. #59
    Registered User
    Join Date
    07-21-2017
    Location
    Toronto, Canada
    MS-Off Ver
    MS Excel 2010
    Posts
    54

    Re: How to split data in one column into two

    The only blank columns I have really are AE, AF, and AG. I'm sorry I should have specified earlier.

  60. #60
    Valued Forum Contributor
    Join Date
    07-10-2017
    Location
    Toronto, Ontario
    MS-Off Ver
    Excel 2013
    Posts
    430

    Re: How to split data in one column into two

    You can try this (it searches for the first blank columns). And no worries, it's always tricky when you don't have access to the actual data.
    Please Login or Register  to view this content.
    Last edited by danielexcelvba; 07-25-2017 at 12:17 PM.

  61. #61
    Registered User
    Join Date
    07-21-2017
    Location
    Toronto, Canada
    MS-Off Ver
    MS Excel 2010
    Posts
    54

    Re: How to split data in one column into two

    Should I redo the yes/no dilemma and then copy that code into the worksheet?

  62. #62
    Valued Forum Contributor
    Join Date
    07-10-2017
    Location
    Toronto, Ontario
    MS-Off Ver
    Excel 2013
    Posts
    430

    Re: How to split data in one column into two

    If you still have your original worksheet saved (with the yes/no stuff complete), you can just paste the new code into that

  63. #63
    Registered User
    Join Date
    07-21-2017
    Location
    Toronto, Canada
    MS-Off Ver
    MS Excel 2010
    Posts
    54

    Re: How to split data in one column into two

    Thank you Daniel. This finally seems to all be working now. I apologise for any inconveniences. Thank you.

  64. #64
    Valued Forum Contributor
    Join Date
    07-10-2017
    Location
    Toronto, Ontario
    MS-Off Ver
    Excel 2013
    Posts
    430

    Re: How to split data in one column into two

    No problem! Glad I could help

  65. #65
    Registered User
    Join Date
    07-21-2017
    Location
    Toronto, Canada
    MS-Off Ver
    MS Excel 2010
    Posts
    54

    Re: How to split data in one column into two

    Hi Daniel

    Here is the screenshot. I inserted an insurance expiry comments column (y) beside column x. Here we don't have to set ongoing to equal the initial date + 10 years, but to simply move ongoing or any other text into the right comment column. Thank you.
    expiredates2.PNG
    Last edited by deleter; 07-28-2017 at 10:52 AM.

  66. #66
    Valued Forum Contributor
    Join Date
    07-10-2017
    Location
    Toronto, Ontario
    MS-Off Ver
    Excel 2013
    Posts
    430

    Re: How to split data in one column into two

    I edited the code from last time to also separate the text from this column. Replace it with the new one and let me know if it works!
    Please Login or Register  to view this content.
    Edit: do you want the comments deleted from column "X"? Right now they're being put in "Y", but are not being deleted

  67. #67
    Valued Forum Contributor
    Join Date
    07-10-2017
    Location
    Toronto, Ontario
    MS-Off Ver
    Excel 2013
    Posts
    430

    Re: How to split data in one column into two

    If you want them deleted (column "X" will now contain dates only), use this
    Please Login or Register  to view this content.

  68. #68
    Registered User
    Join Date
    07-21-2017
    Location
    Toronto, Canada
    MS-Off Ver
    MS Excel 2010
    Posts
    54

    Re: How to split data in one column into two

    Hi Daniel, the comments are ok being left, they don't have to be deleted. I tried the first code you send but I get an error saying Run time error 9 subscript out of range and when I hit debug

    Please Login or Register  to view this content.
    is highlighted yellow. Thoughts?
    Last edited by deleter; 07-28-2017 at 12:43 PM.

  69. #69
    Valued Forum Contributor
    Join Date
    07-10-2017
    Location
    Toronto, Ontario
    MS-Off Ver
    Excel 2013
    Posts
    430

    Re: How to split data in one column into two

    That's really strange. You said the code was working before right? Because I didn't edit that part at all

  70. #70
    Registered User
    Join Date
    07-21-2017
    Location
    Toronto, Canada
    MS-Off Ver
    MS Excel 2010
    Posts
    54

    Re: How to split data in one column into two

    debug.PNG

    Hey yeah it was working. But i noticed that the excel format I was working on didn't save Macros then I changed that so it can be saved as one, I think that might have something to do with it.

  71. #71
    Valued Forum Contributor
    Join Date
    07-10-2017
    Location
    Toronto, Ontario
    MS-Off Ver
    Excel 2013
    Posts
    430

    Re: How to split data in one column into two

    You must have a date in a format that I haven't tested. Try changing >0 to >1 in the line before the highlight maybe?

  72. #72
    Registered User
    Join Date
    07-21-2017
    Location
    Toronto, Canada
    MS-Off Ver
    MS Excel 2010
    Posts
    54

    Re: How to split data in one column into two

    Hi

    So I made the change and this happened...

    debug2.PNG

    Some text values from columns we don't need to worry about shifted over. I feel we're getting there.

  73. #73
    Valued Forum Contributor
    Join Date
    07-10-2017
    Location
    Toronto, Ontario
    MS-Off Ver
    Excel 2013
    Posts
    430

    Re: How to split data in one column into two

    Really not sure why that would happen
    It could just be an issue with it thinking an unused column in the middle of your data is your last column? In which case maybe try this?
    Please Login or Register  to view this content.

  74. #74
    Registered User
    Join Date
    07-21-2017
    Location
    Toronto, Canada
    MS-Off Ver
    MS Excel 2010
    Posts
    54

    Re: How to split data in one column into two

    Hi Daniel, hope you had a great weekend. I tried that latest line of code and I get the same Mismatch Type error, but I think part of it kind of works because column X is the column with the date + text and column y has some of the cells have comments moved into it from x

    debug3.PNG expiry3.PNG

  75. #75
    Valued Forum Contributor
    Join Date
    07-10-2017
    Location
    Toronto, Ontario
    MS-Off Ver
    Excel 2013
    Posts
    430

    Re: How to split data in one column into two

    Ah right blank cells would cause issues with that. Should be fixed
    Please Login or Register  to view this content.

  76. #76
    Registered User
    Join Date
    07-21-2017
    Location
    Toronto, Canada
    MS-Off Ver
    MS Excel 2010
    Posts
    54

    Re: How to split data in one column into two

    Hi Daniel, for some reason this part always comes back highlighted. What does this bit of code mean exactly?

    Cells(i, 24).Value = CDate(Cells(i, 24).Value)

    > Type mismatch error

  77. #77
    Valued Forum Contributor
    Join Date
    07-10-2017
    Location
    Toronto, Ontario
    MS-Off Ver
    Excel 2013
    Posts
    430

    Re: How to split data in one column into two

    That code is attempting to convert the value in column "X" to a date. You must have values that don't resemble dates at all for it to give you an error. You can just delete this part
    Please Login or Register  to view this content.
    But then you will be left with dates in non-date formats in column "X" (e.g. Dec 12 2017)

  78. #78
    Registered User
    Join Date
    07-21-2017
    Location
    Toronto, Canada
    MS-Off Ver
    MS Excel 2010
    Posts
    54

    Re: How to split data in one column into two

    expiry4.PNG I think we're good now thank you. Most of the cells looked like this and most of them are split, I'll manually edit the odd one here and there but this pretty much does the trick. Once again thank you. Sorry for being a pain

  79. #79
    Valued Forum Contributor
    Join Date
    07-10-2017
    Location
    Toronto, Ontario
    MS-Off Ver
    Excel 2013
    Posts
    430

    Re: How to split data in one column into two

    No worries, glad it somewhat worked for you!

+ 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. Split text into column and select last column and specified where to move the data
    By biroulcontabil in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-22-2017, 07:55 AM
  2. [SOLVED] formula or vba to split data column into 2 distinct column
    By JEAN1972 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 09-20-2016, 02:33 PM
  3. [SOLVED] VB Code to split data from Column A and put in Column B,C and D
    By rizmomin in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 08-27-2016, 12:54 PM
  4. Need Macro code to split data split in 7 sheets based on variable rows in column A
    By Alija_21 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 12-31-2015, 08:03 AM
  5. Split Data From Single Column Set Into Multiple Column Sets?
    By slavrenz in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 11-25-2014, 04:33 AM
  6. Data Split from One Column to Another
    By Mohanmoni in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 05-06-2014, 04:21 PM
  7. Split data in column
    By Kat in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 11-02-2005, 10:20 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