+ Reply to Thread
Results 1 to 3 of 3

Want to copy coulumns cells only if another cell in same row is equal to a value.

  1. #1
    Registered User
    Join Date
    07-18-2013
    Location
    Cincinnati
    MS-Off Ver
    2010
    Posts
    35

    Want to copy coulumns cells only if another cell in same row is equal to a value.

    I need to modify this code I used in another workbook, to copy and paste columns, but leave out rows that do not contain "Yes" in a different column in the same row.

    Please Login or Register  to view this content.
    Basically I want it to take each cell in a column, and copy and paste if in another column, same row has "Yes".

    Example:

    ID-----------Successful?
    Fred---------Yes
    Bob----------No
    John---------No
    Jake---------Yes

    So it would copy Fred and Jake and paste those values into a worksheet on another workbook.

    I am guessing I need to use some sort of for statement?
    Last edited by Jhail83; 01-13-2014 at 02:23 PM.

  2. #2
    Registered User
    Join Date
    07-18-2013
    Location
    Cincinnati
    MS-Off Ver
    2010
    Posts
    35

    Re: Want to copy coulumns cells only if another cell in same row is equal to a value.

    For the Copying and Pasting I have this:

    Please Login or Register  to view this content.
    I am unsure to as why it will not get the Column Index number for this line:
    intColNum2 = WorksheetFunction.Match("FLEET_ID", wsExport.Range("1:1"), 0)

    but not for this line:
    intColNum2 = WorksheetFunction.Match("FLEET_ID", wsImport.Range("1:1"), 0)

    wsImport is set to the active sheet. But it says "Run time error 1004. Unable to get the Match Function of the WorksheetProperty Class"

    I'd prefer not to hardcode the Index in, as there may be columns added. It is unlikely that the Column names will change.
    Last edited by Jhail83; 01-13-2014 at 03:18 PM.

  3. #3
    Registered User
    Join Date
    07-18-2013
    Location
    Cincinnati
    MS-Off Ver
    2010
    Posts
    35

    Re: Want to copy coulumns cells only if another cell in same row is equal to a value.

    Sorry for the triple post, but I actually want to refine my request for help.

    Copying cell by cell is slow, so I was wondering, could I just filter the "Success" column to only show rows with a "Y" value through VBA and copy and paste the remaining fields in the columns I want? What if I wanted to filter by that, and then filter by a date column for dates in a given year?
    Last edited by Jhail83; 01-13-2014 at 04:19 PM.

+ 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] Copy entire row from one sheet to another if cells in column A are equal
    By Scal in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 06-12-2013, 12:27 PM
  2. Compare 2 cells if equal then copy...
    By stimea in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-08-2012, 06:14 AM
  3. Replies: 8
    Last Post: 10-19-2011, 06:17 PM
  4. Check if two cells are equal and copy,paste cell if true
    By solomeros in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-29-2011, 01:22 AM
  5. Check if two cells are equal, copy/paste adiacent cell
    By Macuil0101 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-15-2011, 12:40 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