+ Reply to Thread
Results 1 to 7 of 7

text to column

  1. #1
    Forum Contributor
    Join Date
    02-18-2014
    Location
    hk
    MS-Off Ver
    Excel 365
    Posts
    105

    text to column

    Hi All,

    I have encounter for text to column. my data is as below

    Range ("A1")=2008 76 294 (0) 69 683 (+7) 145 977 (+3) 43 021 (+18) 70 404 (+4) 113 425 (+9) 259 402 (+6)
    Range("A2"=2009 76 240 (0) 63 053 (-10) 139 293 (-5) 38 626 (-10) 65 048 (-8) 103 673 (-9) 242 967 (-6)

    the first word of the sentence is year and the separator is the bucket. I need to remove space in the data.
    I want the table to be as below

    2008 76294 69683 145977 43021 ...
    2009 76240 63053 139293 38626 ...

    I think the difficult to change the bucket to a separator.
    Thanks in advance.

  2. #2
    Valued Forum Contributor quekbc's Avatar
    Join Date
    01-18-2010
    Location
    Sydney, Australia
    MS-Off Ver
    2010, 2013, 2016
    Posts
    1,149

    Re: text to column

    RAA! I typed all the steps out, and when I was trying to insert pictures it failed, reload the site, and lost all my comments.

    Anyhoo, you can do this in a few steps. I'm sure someone here will have a more efficient method but this is what I have on top of my head.

    1) Do a Find and Replace All (Ctrl + H) and find "(*)", and replace it with ","
    Step1.jpg
    2) Then do a Text To Column: Delimited --> Comma
    Step2.jpg
    3) You should have in column A numbers that look like 2009 76 294.
    4) In columns B onwards, you should have numbers without the year (e.g. 69 683)

    To deal with column A
    A1) Insert 2 columns after column A
    A2) To extract year, in new column B,
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    A3) To extract remaining numbers, in new column C,
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    A4) Copy columns B and C and Paste Special --> Values

    To deal with the spaces in the numbers
    1) Do another Find and Replace All (Ctrl + H) and find " " and replace with ""
    2) Note: the picture below you won't see any characters in the Find and Replace field, but know that the Find field will have 1 space in there, the Replace field will have nothing
    Step3.jpg

    EDIT: Or you can automate all of the steps above using VBA
    Last edited by quekbc; 06-24-2015 at 12:40 AM.

  3. #3
    Forum Contributor
    Join Date
    02-18-2014
    Location
    hk
    MS-Off Ver
    Excel 365
    Posts
    105

    Re: text to column

    Thank you. I think I can write the macro using your concept.
    Quote Originally Posted by quekbc View Post
    RAA! I typed all the steps out, and when I was trying to insert pictures it failed, reload the site, and lost all my comments.

    Anyhoo, you can do this in a few steps. I'm sure someone here will have a more efficient method but this is what I have on top of my head.

    1) Do a Find and Replace All (Ctrl + H) and find "(*)", and replace it with ","
    Attachment 402998
    2) Then do a Text To Column: Delimited --> Comma
    Attachment 402999
    3) You should have in column A numbers that look like 2009 76 294.
    4) In columns B onwards, you should have numbers without the year (e.g. 69 683)

    To deal with column A
    A1) Insert 2 columns after column A
    A2) To extract year, in new column B,
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    A3) To extract remaining numbers, in new column C,
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    A4) Copy columns B and C and Paste Special --> Values

    To deal with the spaces in the numbers
    1) Do another Find and Replace All (Ctrl + H) and find " " and replace with ""
    2) Note: the picture below you won't see any characters in the Find and Replace field, but know that the Find field will have 1 space in there, the Replace field will have nothing
    Attachment 403000

    EDIT: Or you can automate all of the steps above using VBA

  4. #4
    Forum Expert NeedForExcel's Avatar
    Join Date
    03-16-2013
    Location
    Pune, India
    MS-Off Ver
    Excel 2016:2019, MS 365
    Posts
    3,876

    Re: text to column

    Hi,

    Try this -

    Put this Code

    Option Explicit

    Please Login or Register  to view this content.
    Then use this formula -

    Please Login or Register  to view this content.
    Check the attached file. Sheet named Input has the Input Text Strings and sheet named Output has Output text strings with | as delimiter..

    You can then use Text to Columns using | as delimiter..

    Hope it helps..

    Deep
    Attached Files Attached Files
    Cheers!
    Deep Dave

  5. #5
    Forum Contributor
    Join Date
    02-18-2014
    Location
    hk
    MS-Off Ver
    Excel 365
    Posts
    105

    Re: text to column

    Thanks. I just want to reply that
    Please Login or Register  to view this content.
    is not effective in vba. and Luckily read your reply.
    Quote Originally Posted by NeedForExcel View Post
    Hi,

    Try this -

    Put this Code

    Option Explicit

    Please Login or Register  to view this content.
    Then use this formula -

    Please Login or Register  to view this content.
    Check the attached file. Sheet named Input has the Input Text Strings and sheet named Output has Output text strings with | as delimiter..

    You can then use Text to Columns using | as delimiter..

    Hope it helps..

    Deep

  6. #6
    Forum Expert NeedForExcel's Avatar
    Join Date
    03-16-2013
    Location
    Pune, India
    MS-Off Ver
    Excel 2016:2019, MS 365
    Posts
    3,876

    Re: text to column

    I am not sure what you mean?

    So did my solution not help you with what you wanted?

  7. #7
    Valued Forum Contributor quekbc's Avatar
    Join Date
    01-18-2010
    Location
    Sydney, Australia
    MS-Off Ver
    2010, 2013, 2016
    Posts
    1,149

    Re: text to column

    Quote Originally Posted by NeedForExcel View Post
    I am not sure what you mean?

    So did my solution not help you with what you wanted?
    I think what he means is that he wasn't able to do the replace in VBA effectively and is now trying your method.

    mrkhchan: I like how you are taking in solutions and trying to adjust it yourself and I applaud you for that. I think it is the best way to learn. If it is of any help, the Replace function you are referring to is the VBA Replace function. You can utilise the Find & Replace tool in Excel (Ctrl F or Ctrl H) by using
    Please Login or Register  to view this content.
    instead.

+ 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. Filter column by text, then export column to new workbook, replace searched text with new.
    By Headhunter234 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-30-2015, 07:48 AM
  2. Replies: 4
    Last Post: 11-10-2014, 07:21 AM
  3. Text&number based column to auto display new text in new column
    By TCF in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 01-24-2014, 01:56 PM
  4. Replies: 12
    Last Post: 01-08-2014, 11:28 AM
  5. Trying to write amacro to compare text in column A to garbage text in column B
    By Big Dawg Dad in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-19-2013, 03:31 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