+ Reply to Thread
Results 1 to 8 of 8

search column for text, if found, paste value in a different column in new sheet

  1. #1
    Registered User
    Join Date
    08-14-2012
    Location
    NY
    MS-Off Ver
    Excel 2010
    Posts
    3

    search column for text, if found, paste value in a different column in new sheet

    Hi, I'm new to macros and variants of this question is probably asked all the time, but I'm having trouble copying certain parts of my data to a new worksheet. What I want is an Excel macro to search Sheet1 column A, find a value ("K" for example), and if found, paste the corresponding value in column B into Sheet2 ("column C"), for example. Then I want it to go through all the Ks in the column.

    Then I want to run another search for "V" and if found, paste the corresponding value in column B into Sheet2 Column D this time.

    I would like to have the data separated by Accounts.

    So the data looks like this:

    Sheet 1
    Acct A - K - 50 - $2
    Acct A - K - 100 - $3
    Acct A - V - 75 - $2
    Acct B - K - 25 - $1
    Acct B - K - 100 - $1
    Acct B - V - 50 - $1
    Acct B - V - 75 - $1

    And I want the output to look like this:

    Sheet 2
    Acct A - 50 - - $2
    Acct A - 100 - - $3
    Acct A - - 75 - $2

    Acct B - 25 - - $1
    Acct B - 100 - - $1
    Acct B - - 50 - $1
    Acct B - - 75 - $1

    (Each dash signifies a different column)

    I have searched this forum and many others, got a bunch of codes but I wasn't able to tweak them to work for my particular situation. Any help would be much appreciated.

  2. #2
    Forum Expert
    Join Date
    07-15-2012
    Location
    Leghorn, Italy
    MS-Off Ver
    Excel 2010
    Posts
    3,431

    Re: search column for text, if found, paste value in a different column in new sheet

    attach please a sample with before and after

  3. #3
    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,939

    Re: search column for text, if found, paste value in a different column in new sheet

    @ patel45, i think the OP's request and description pretty clearly states what he wants
    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

  4. #4
    Forum Expert
    Join Date
    07-15-2012
    Location
    Leghorn, Italy
    MS-Off Ver
    Excel 2010
    Posts
    3,431

    Re: search column for text, if found, paste value in a different column in new sheet

    Maybe you are right, but I'm lazy and not very intelligent

  5. #5
    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,939

    Re: search column for text, if found, paste value in a different column in new sheet

    lol, im sure you are neither

  6. #6
    Registered User
    Join Date
    08-14-2012
    Location
    NY
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: search column for text, if found, paste value in a different column in new sheet

    patel45,

    Thanks for the reply. I attached the example I posted. I've figured out that what I need is an If Then ElseIf statement to separate the Ks and the Vs and then a Loop to make Excel go through all the data, but I'm not savvy enough to write the code on my own just yet.

    There's also the problem of inserting blank rows after each account. Some of these accounts go on forever, so I wasn't sure how to insert them after Excel recognizes it has gone through the data for one account.
    Attached Files Attached Files

  7. #7
    Forum Expert
    Join Date
    07-15-2012
    Location
    Leghorn, Italy
    MS-Off Ver
    Excel 2010
    Posts
    3,431

    Re: search column for text, if found, paste value in a different column in new sheet

    Please Login or Register  to view this content.
    Last edited by patel45; 08-15-2012 at 03:10 PM.

  8. #8
    Registered User
    Join Date
    08-14-2012
    Location
    NY
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: search column for text, if found, paste value in a different column in new sheet

    patel45, that is amazing. Thanks!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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