+ Reply to Thread
Results 1 to 9 of 9

Loop Range, Copy Cell if Row contains "xyz". Next row...

  1. #1
    Registered User
    Join Date
    10-15-2013
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    14

    Loop Range, Copy Cell if Row contains "xyz". Next row...

    So i need to Loop a range, well say A3:CZ2000. Header row is 2. If the loops finds "xyz" it copies the header cell in that column.

    Example:

    T17 contains "xyz", T2 is copied and pasted to another worksheet along with a few other cells from that row
    Next loop
    BC24 contains "xyz", BC2 is copied and pasted to another worksheet along with a few other cells from that row


    Please Login or Register  to view this content.

    Im at a loss for how to bring all this together
    Last edited by JBeaucaire; 10-29-2013 at 08:33 PM.

  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: Loop Range, Copy Cell if Row contains "xyz". Next row...

    A small workbook with two sheets... one with a 10-20 rows of sample data in the exact format, the other with the manual mockup of the RESULTS you want from that sample data...

    That will get you a proper 100% ready to use answer, and quickly since no one will have to create a wb to test their ideas on.


    Click on GO ADVANCED and use the paperclip icon to open the upload window.

    View Pic
    _________________
    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
    10-15-2013
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    14

    Re: Loop Range, Copy Cell if Row contains "xyz". Next row...

    Thanks! Ill do that right now.

  4. #4
    Registered User
    Join Date
    10-15-2013
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    14

    Re: Loop Range, Copy Cell if Row contains "xyz". Next row...

    ExampleDataAndResult.xlsx

    Here you go, hopefully that helps!

  5. #5
    Registered User
    Join Date
    10-15-2013
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    14

    Re: Loop Range, Copy Cell if Row contains "xyz". Next row...

    Heck I'd even appreciate if someone could tell me how to properly reference a range using a variable as the row, like:

    Please Login or Register  to view this content.
    Im sure this is possible, just dont know how to do it

  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: Loop Range, Copy Cell if Row contains "xyz". Next row...

    Quotations are used to separate pieces of strings, then the & operator connects them.

    Please Login or Register  to view this content.

  7. #7
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Loop Range, Copy Cell if Row contains "xyz". Next row...

    The output is in sheet3
    Attached Files Attached Files

  8. #8
    Registered User
    Join Date
    10-15-2013
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    14

    Re: Loop Range, Copy Cell if Row contains "xyz". Next row...

    This was great thank you so much for your time!

  9. #9
    Registered User
    Join Date
    10-15-2013
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    14

    Re: Loop Range, Copy Cell if Row contains "xyz". Next row...

    Quote Originally Posted by AB33 View Post
    The output is in sheet3

    I am getting an Error 9 however. on this line

    Please Login or Register  to view this content.
    Subscript out of range. Any ideas? There are are a few more columns in my original spreadsheet that i omitted.

+ 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. [SOLVED] How to copy into next empty row using "for each cell in range" loop
    By GIS2013 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-23-2013, 02:30 PM
  2. Replies: 2
    Last Post: 09-12-2013, 10:56 PM
  3. [SOLVED] Loop to check for "yes" then copy the IDs with "yes" and paste to other workbook
    By Hallet in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-11-2012, 12:41 PM
  4. Replies: 3
    Last Post: 06-04-2011, 10:56 AM
  5. How can i copy value from "HTMLText"(EMBED("Forms.HTML:Text","")),using Macro
    By andrewyang in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-18-2010, 12:47 AM

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