+ Reply to Thread
Results 1 to 10 of 10

Copy row based off entry in either of two columns

  1. #1
    Forum Contributor
    Join Date
    10-26-2011
    Location
    Ottawa, ON Canada
    MS-Off Ver
    Excel 2011 for Mac
    Posts
    128

    Copy row based off entry in either of two columns

    I'm trying to alter the below code slightly. It currently looks at column M (13) and if it has an entry, it will select that row (from A:AE) and copy to clipboard.

    I'd like to change it so it would look at either 19 (column S), or 32 (AF) and select/copy to clipboard A:BS if either cell has an entry

    For example AF6 has data, the macro will copy A6:BS6
    If AF6 has nothing, but S6 has data, it will also copy A6:BS6

    It could also be the other way round. S6 is blank, but AF6 has data, it will copy A6:BS6


    Please Login or Register  to view this content.

  2. #2
    Valued Forum Contributor natefarm's Avatar
    Join Date
    04-22-2010
    Location
    Wichita, Kansas
    MS-Off Ver
    2016
    Posts
    1,020

    Re: Copy row based off entry in either of two columns

    Please Login or Register  to view this content.
    Acts 4:12
    Salvation is found in no one else, for there is no other name under heaven given to mankind by which we must be saved.

  3. #3
    Forum Contributor
    Join Date
    10-26-2011
    Location
    Ottawa, ON Canada
    MS-Off Ver
    Excel 2011 for Mac
    Posts
    128

    Re: Copy row based off entry in either of two columns

    Thanks Natefarm. Works great. Just one thing, it needs to start at Row 6, not before. I have headers and totals in Rows 1-5 that should not be selected.

  4. #4
    Valued Forum Contributor natefarm's Avatar
    Join Date
    04-22-2010
    Location
    Wichita, Kansas
    MS-Off Ver
    2016
    Posts
    1,020

    Re: Copy row based off entry in either of two columns

    Just start with rw = 4 instead of 1.

  5. #5
    Forum Contributor
    Join Date
    10-26-2011
    Location
    Ottawa, ON Canada
    MS-Off Ver
    Excel 2011 for Mac
    Posts
    128

    Re: Copy row based off entry in either of two columns

    Perfect! Thanks again.

  6. #6
    Forum Contributor
    Join Date
    10-26-2011
    Location
    Ottawa, ON Canada
    MS-Off Ver
    Excel 2011 for Mac
    Posts
    128

    Re: Copy row based off entry in either of two columns

    Hi Nate - I'm trying the above but changing it to only Select the rows. I simply changed .Copy to .Select.

    It seems to highlight, but then if I go to a Data Sort it says it can't as multiple selections are chosen, even though it appears it's only one selection.

    Should the above VBA work the same ending with .Select?

    Thanks.

  7. #7
    Valued Forum Contributor natefarm's Avatar
    Join Date
    04-22-2010
    Location
    Wichita, Kansas
    MS-Off Ver
    2016
    Posts
    1,020

    Re: Copy row based off entry in either of two columns

    The code is selecting the rows one at a time, rather than as a block, just as if you selected several rows one at a time using the Ctrl key, and in theory, there could be blank rows in-between, so I don't think you'll be able to sort on the selection the way it's coded.

  8. #8
    Forum Contributor
    Join Date
    10-26-2011
    Location
    Ottawa, ON Canada
    MS-Off Ver
    Excel 2011 for Mac
    Posts
    128

    Re: Copy row based off entry in either of two columns

    Ok. Makes sense.

    Is it possible to change it so it selects as a block for the Select VBA. The Select option is only used when the rows are confirmed as having data in blocks.

  9. #9
    Valued Forum Contributor natefarm's Avatar
    Join Date
    04-22-2010
    Location
    Wichita, Kansas
    MS-Off Ver
    2016
    Posts
    1,020

    Re: Copy row based off entry in either of two columns

    This should do it.
    Please Login or Register  to view this content.

  10. #10
    Forum Contributor
    Join Date
    10-26-2011
    Location
    Ottawa, ON Canada
    MS-Off Ver
    Excel 2011 for Mac
    Posts
    128

    Re: Copy row based off entry in either of two columns

    Perfect. Thanks again! And sorry, that was probably not the correct way of asking for further help on a closed thread...

+ 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. Replies: 8
    Last Post: 01-15-2013, 01:39 PM
  2. Disable Entry in Columns based on the Filter
    By gaurde in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-29-2012, 08:03 PM
  3. Replies: 3
    Last Post: 04-27-2010, 01:47 AM
  4. Hide columns based on a user entry
    By MarkAnderson in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-28-2009, 04:55 PM
  5. Copy Row based on cell entry
    By Sharp in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-07-2008, 08:43 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