+ Reply to Thread
Results 1 to 11 of 11

Select and copy text after specified word macro

Hybrid View

  1. #1
    Registered User
    Join Date
    05-09-2012
    Location
    Hungary
    MS-Off Ver
    Excel 2007
    Posts
    5

    Select and copy text after specified word macro

    Hy!

    I have a huge ammount of exported data, and one cell contains the category name and the category path too. I want to write a macro, which can find the category name, copy and paste it to an other cell, and the same for the path too.

    Example:

    Cell looks like this:
    Category Name: ProductNameSomething, Category Path: Materials/Alloys/Something

    And I need the macro to copy the ProductNameSomething and Materials/Alloys/Something to other cells (wothout the "Category Name:" and the "Category Path:").

    I would really appriciate some help, how can I select and copy text in a cell after a specified word? Or is there any easier solution?

  2. #2
    Valued Forum Contributor
    Join Date
    02-09-2012
    Location
    Mauritius
    MS-Off Ver
    Excel 2007
    Posts
    1,055

    Re: Select and copy text after specified word macro

    Hi

    Uploading the sample file will be a great help... You can extract few records...
    Click *, if my suggestion helps you. Have a good day!!

  3. #3
    Registered User
    Join Date
    05-09-2012
    Location
    Hungary
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: Select and copy text after specified word macro

    Right, I made a sample.

    The character decoding is superweird, thats a website issue to solve for an other co-worker.

    sample.xlsx

  4. #4
    Valued Forum Contributor
    Join Date
    02-09-2012
    Location
    Mauritius
    MS-Off Ver
    Excel 2007
    Posts
    1,055

    Re: Select and copy text after specified word macro

    There are cells where only category path exists... What do you want to do abt those data?

  5. #5
    Registered User
    Join Date
    05-09-2012
    Location
    Hungary
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: Select and copy text after specified word macro

    skip it (make a blank cell), so I can easily know, there was something wrong.

  6. #6
    Forum Expert
    Join Date
    09-27-2011
    Location
    Poland
    MS-Off Ver
    Excel 2007
    Posts
    1,312

    Re: Select and copy text after specified word macro

    Hi select column A and run this code
    Sub aa()
    Dim k As Range
    Dim x As Integer
    Dim ar, temp As Variant
    ar = Array("Category Name: ", "Category Path: ")
    For Each k In Selection
            x = 0
            temp = Replace(Replace(k.Value, ar(x), ""), ar(x), "")
            x = x + 1
            k.Offset(0, 1) = Replace(temp, ar(x), "")
            Next
    End Sub
    Regards

    tom1977

    If You are satisfied with my solution click the small star icon on the left to say thanks.

  7. #7
    Valued Forum Contributor
    Join Date
    02-09-2012
    Location
    Mauritius
    MS-Off Ver
    Excel 2007
    Posts
    1,055

    Re: Select and copy text after specified word macro

    Try this too:

    sample (3).xlsm

  8. #8
    Registered User
    Join Date
    05-09-2012
    Location
    Hungary
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: Select and copy text after specified word macro

    The code is almost perfect! Is it possible, to move only the name into column B and the path into column C?

    Edit: the sample, you attached works perfectly! Thank you very much.
    Last edited by pongi; 05-09-2012 at 08:01 AM.

  9. #9
    Valued Forum Contributor
    Join Date
    02-09-2012
    Location
    Mauritius
    MS-Off Ver
    Excel 2007
    Posts
    1,055

    Re: Select and copy text after specified word macro

    Now you can try it again:

    sample (3).xlsm

  10. #10
    Registered User
    Join Date
    05-09-2012
    Location
    Hungary
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: Select and copy text after specified word macro

    perfect, thanks!

  11. #11
    Valued Forum Contributor
    Join Date
    02-09-2012
    Location
    Mauritius
    MS-Off Ver
    Excel 2007
    Posts
    1,055

    Re: Select and copy text after specified word macro

    You are welcome...

    If the probs solved then pls click the star below the post...

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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