+ Reply to Thread
Results 1 to 6 of 6

Macro to search cell data and copy data to another workbook

  1. #1
    Registered User
    Join Date
    03-09-2011
    Location
    utah, usa
    MS-Off Ver
    excel 2007
    Posts
    23

    Macro to search cell data and copy data to another workbook

    Hi,

    I am looking for a macro to search all cells and find product?categoryID= and after the = sign to copy the 15 numbers and paste those numbers to another workbook called categorycopy on column a. Then the row underneath it will have target="_self">Card Reader</a></li> I need the data in between _self"> and </a></li> then copy it to workbook category to column b

    I have attached an example spreadsheet on the data that needs to be searched & copied over.

    thanks for your help

    testcategories.xlsx

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Macro to search cell data and copy data to another workbook

    This should do it. Put this macro into the workbook where you want to collect the data. Be sure to edit the wsCat string to point to the correct sheetname in that workbook.

    Then, bring up a data sheet onscreen to process and run the macro:

    Please Login or Register  to view this content.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Registered User
    Join Date
    03-09-2011
    Location
    utah, usa
    MS-Off Ver
    excel 2007
    Posts
    23

    Re: Macro to search cell data and copy data to another workbook

    Sorry i didn't get back to you until now because i have been away. Works exactly as intended thank you!, However i noticed that it only grabbed the main category headings and not the sub category headings. If you look at the new attached spreadsheet on line 617 this is where it starts. This was my mistake because i thought the sub category headings were included.

    The only way that i can see to search would be <a href="/product?categoryid="and after the 15 numbers ">value example</a>
    FYI - the old one didn't have <a href=" and its all on the same row.

    This is an example of a main & sub category heading below and on the sheet.
    New


    <h1><a href="/product?categoryId=200000000000000">Component</a></h1>
    <h4><a href="/product?categoryId=222000000000000">Cable</a></h4>
    <h5><a href="/product?categoryId=222010000000000">Cable Sleeving Kit</a><h5>
    <h5><a href="/product?categoryId=222020000000000">Cat5 Cable</a><h5>

    Old
    href="/product?categoryId=316000000000000"
    target="_self">Webcam</a></li>

    href="/product?categoryId=315000000000000"
    target="_self">Televison</a></li>
    categoriesfull.xlsx

  4. #4
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Macro to search cell data and copy data to another workbook

    So a little IF/THEN helps decide where the name string comes from...

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    03-09-2011
    Location
    utah, usa
    MS-Off Ver
    excel 2007
    Posts
    23

    Cool Re: Macro to search cell data and copy data to another workbook

    Wow your good, its exactly what i need. thanks for your help and marked excellent for your help.

  6. #6
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Macro to search cell data and copy data to another workbook

    If that takes care of your need, please select Thread Tools from menu above and set this topic to SOLVED.

+ 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