+ Reply to Thread
Results 1 to 20 of 20

Copy and paste to one row based on matching values

  1. #1
    Registered User
    Join Date
    06-24-2015
    Location
    Chicago
    MS-Off Ver
    2007 Excel
    Posts
    14

    Copy and paste to one row based on matching values

    I have a list of account numbers, in order, that might have 2-3 of the same account number in the rows below it based on a column that has a different value in it. I need to copy and paste that different value to the first row that account number appeared, in the next available column in that row, then move to the next new account number and repeat. Appreciate any help.

    Thanks

  2. #2
    Forum Expert
    Join Date
    05-20-2015
    Location
    Chicago, Illinois
    MS-Off Ver
    2016
    Posts
    2,103

    Re: Copy and paste to one row based on matching values

    This sounds possible, but it would require a sample workbook in order to really provide any help. Are you able to post a small sample workbook (use: Go Advanced --> Manage Attachments) with all sensitive information altered or removed?

  3. #3
    Registered User
    Join Date
    06-24-2015
    Location
    Chicago
    MS-Off Ver
    2007 Excel
    Posts
    14

    Re: Copy and paste to one row based on matching values

    Basically I need to compare column B (acct#) for matching numbers. If there is a match then it needs to validate column a (Ordered Y/N) for a "Y" to move the contents of column d to the first row that account number appears. Attached is what it should look like when finished.

    Thanks
    Attached Files Attached Files

  4. #4
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 2019
    Posts
    17,882

    Re: Copy and paste to one row based on matching values

    If you are open to a formula solution:
    1) Select E2,
    2) paste the following array entered formula* into the formula bar:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    3) activate by simultaneously pressing the Ctrl, Shift and Enter keys.
    *If you attempt to activate by only pressing the Enter key no value (blank) will display in E2.
    Let us know if you have any questions.
    Consider taking the time to add to the reputation of everybody that has taken the time to respond to your query.

  5. #5
    Registered User
    Join Date
    06-24-2015
    Location
    Chicago
    MS-Off Ver
    2007 Excel
    Posts
    14

    Re: Copy and paste to one row based on matching values

    Thanks for the formula. The only problem is that if there were three acct #s with y in column a it doesn't fill in the next available column. This is what it should do when there are 3,4,5 etc of the same acct # with y in column a.
    Attached Files Attached Files

  6. #6
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 2019
    Posts
    17,882

    Re: Copy and paste to one row based on matching values

    Then lets try this two formula solution. The first column, E, is populated by the formula:
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Subsequent columns are populated by the formula:
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Let us know if you have any questions.
    Attached Files Attached Files

  7. #7
    Registered User
    Join Date
    06-24-2015
    Location
    Chicago
    MS-Off Ver
    2007 Excel
    Posts
    14

    Re: Copy and paste to one row based on matching values

    Appreciate your help. The only other concern is when there are three account numbers in a row with Y-N-Y in column A. It will skip the second Y which is the third time the acct number appears. Would it be possible to account for that? I attached a sample of what it looks like when it isn't Y-Y-Y.

    Thanks
    Attached Files Attached Files

  8. #8
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 2019
    Posts
    17,882

    Re: Copy and paste to one row based on matching values

    Feel like I am getting close. The issue is that there are two cases. The case where the 'Last 4' is the same as the 'Account' as in row 2, and the case where the 'Last 4' is different from the 'Account' as in row 10. The formula that handles the case in row 10 is:
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    The array entered formula (see post #4 for activation) that handles the case in row 2, and the remainder of the yellow shaded table is:
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    I am having a hard time getting the two married up, but will get back to work on this in the morning, provided someone else hasn't solved it by then.
    Let us know if you have any questions.
    Attached Files Attached Files

  9. #9
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 2019
    Posts
    17,882

    Re: Copy and paste to one row based on matching values

    An array entered formula* (see post #4) that will do what you want is:
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Let us know if you have any questions.
    Attached Files Attached Files

  10. #10
    Registered User
    Join Date
    06-24-2015
    Location
    Chicago
    MS-Off Ver
    2007 Excel
    Posts
    14

    Re: Copy and paste to one row based on matching values

    Thanks! The issue now is that the formula seems to work well in row 2, but further down in the sample it's pulling in the last 4 of the first acct # in the next blank cell in column E (E:10).

  11. #11
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 2019
    Posts
    17,882

    Re: Copy and paste to one row based on matching values

    I got myself confused. I thought that E10 should display 5654 since it was different from 1239. However, since that isn't the case it seems that the second (array entered) formula* in post #8 is all that is needed.
    - Select cell E2,
    - paste the second formula from post #8 into the formula bar,
    - *simultaneously press Ctrl,Shift and Enter.
    You may then double click the fill handle to copy the formula down, and copy to the right as far as needed.
    Let us know if you have any questions.

  12. #12
    Registered User
    Join Date
    06-24-2015
    Location
    Chicago
    MS-Off Ver
    2007 Excel
    Posts
    14

    Re: Copy and paste to one row based on matching values

    Works perfectly! Appreciate your help and time!

    Thanks

  13. #13
    Registered User
    Join Date
    02-27-2013
    Location
    Dothan, AL
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: Copy and paste to one row based on matching values

    Could this be done in vb instead? I have similar issue.

  14. #14
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 2019
    Posts
    17,882

    Re: Copy and paste to one row based on matching values

    You're Welcome and thank you for the feedback. Please take a moment to mark the thread as 'Solved' using the thread tools link above your first post. I hope that you have a blessed day.

  15. #15
    Registered User
    Join Date
    06-24-2015
    Location
    Chicago
    MS-Off Ver
    2007 Excel
    Posts
    14

    Re: Copy and paste to one row based on matching values

    I would be interested in the vba as well. The only complaint with the formula is that it is a little laggy with only 1500 rows of data.

  16. #16
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,701

    Re: Copy and paste to one row based on matching values

    VBA for the data in post #3
    Please Login or Register  to view this content.

  17. #17
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 2019
    Posts
    17,882

    Re: Copy and paste to one row based on matching values

    The set up of sheet 2 in the attached file may be a less simple, however it may cause less lag in calculation. The proposed solution on sheet 2 uses four helper columns (XFA:XFD). The formula for the first helper column is:
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    The array entered formula* (see post #4) for the remaining columns is:
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Note that with 1500 rows of data you will probably need more than 3 columns for the second formula.
    If the problem with lag has to do with the computer stalling when data is being entered into columns A:D then you may want to consider changing the calculation mode for the workbook to manual as mentioned in this article (tip #9) and this article.
    Let us know if you have any questions.
    Attached Files Attached Files

  18. #18
    Registered User
    Join Date
    02-27-2013
    Location
    Dothan, AL
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: Copy and paste to one row based on matching values

    This worked great. Thanks

  19. #19
    Registered User
    Join Date
    06-24-2015
    Location
    Chicago
    MS-Off Ver
    2007 Excel
    Posts
    14

    Re: Copy and paste to one row based on matching values

    Worked great and saved a lot of time. Appreciate your efforts both JeteMc and Jindon! Just marked as solved.

  20. #20
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 2019
    Posts
    17,882

    Re: Copy and paste to one row based on matching values

    You're Welcome. Thank You for the feedback and for marking the thread as 'Solved'. I hope that you have a blessed day.

+ 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 paste values to another workbook based on multiple cell values
    By Bazinga in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-23-2014, 12:41 PM
  2. Copy paste values to a cell with matching date
    By Beggar in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-03-2014, 12:49 AM
  3. Replies: 3
    Last Post: 11-26-2013, 04:53 AM
  4. Replies: 1
    Last Post: 11-25-2013, 09:30 AM
  5. [SOLVED] Report to copy paste data based on matching criteria
    By The_Snook in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 10-07-2013, 12:47 PM
  6. Copy/Paste range of cells to another worksheet based on matching criteria
    By maa50904 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-05-2013, 12:07 AM
  7. [SOLVED] Copy and paste based on two values
    By WVSpelunker in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-16-2012, 01:52 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