+ Reply to Thread
Results 1 to 10 of 10

Auto copy & paste

  1. #1
    Registered User
    Join Date
    07-22-2011
    Location
    Rock Island, Illinois
    MS-Off Ver
    Excel 2007
    Posts
    7

    Auto copy & paste

    I need a way to automatically copy and paste cells from a qualifying previous row.

    For example:
    1) I Enter data (text only) in cell B100 and exit that cell.
    2) Cell B20 (closest & previous) happens to match data entered in B100
    3) First 12 cells in row 20 are copied and pasted over first 12 cells in row 100
    4) Row 100 is used for additional manual processing then deleted

    Rows 100 and 20 are examples... other combinations are possible

    I'm fairly good with excell and a rooky with VBA, but I'm learning.
    Last edited by clinet; 07-25-2011 at 07:29 PM.

  2. #2
    Registered User
    Join Date
    06-29-2011
    Location
    California
    MS-Off Ver
    Excel 2003/2007
    Posts
    58

    Re: Auto copy & paste

    You could use simply in cell formula (no need for for vba).

    In Row 100, Column A... you could use the following formula and just apply it to the rest of the cells to the right using the drag feature in excel (of course skip over column B since that's the cell you want to trigger and is manually entered into)...

    Please Login or Register  to view this content.
    ^^the above basically says, if B20 is equal to B100, then display value A12, else display nothing.

    I understand you want more combinations, but I'm not sure exactly how you want them to function, so more explanation = more help in writing your formula/vba, but this should at least get you started.

  3. #3
    Registered User
    Join Date
    07-22-2011
    Location
    Rock Island, Illinois
    MS-Off Ver
    Excel 2007
    Posts
    7

    Re: Auto copy & paste

    Thanks docMed. I'll give your suggestion a try to get things rolling.

    This is indeed simple, but a little short of demand. What I meant by "any combination" was the the first occurance could be any row in the sheet followed by more occurances. In my example row 100 is a copy of row 20... row 101 could be a copy of row 5... row 102 a copy of row 15 and so on.
    They would usually be stacked like this, but not necessarily. That's why I hinted at VBA. Wouldn't a ready-armed tool be more user friendly than propogating formulas prior to an event?

    Wouldn't using formulas leave the established stack subject to alteration due to changes made to any or all rows above the stack. This dynamic might be useful in some respects, but not what I would wan't in my current need.
    Last edited by clinet; 07-23-2011 at 09:28 AM.

  4. #4
    Valued Forum Contributor
    Join Date
    11-11-2008
    Location
    Euro
    MS-Off Ver
    2007, 2010
    Posts
    470

    Re: Auto copy & paste

    Quote Originally Posted by clinet View Post
    3) First 12 cells in row 20 are copied and pasted over first 12 cells in row 100
    4) Row 100 is used for additional manual processing then deleted
    ....
    you mean:

    - after enter data in cell Bn (n=100 in your example)
    - copy value of the first 12 cells Ak:Lk from the row k (k=20 in your example) in that cell Bk contains value =Bn (B20=B100) -- search the condition in database B2:B99

    and continue for the next row with B100 added to the database (B2:B100 for B101)

    ------------
    is that right?

    You desire the solution by formula? or VBA?

    How large is your data? (for example if the database more than thousands - the VBA solution should be consisdered)

    the last but not least, you should post a sample file (with dummy data) in order to it is easy to understand and take advantage for others' help
    Last edited by tigertiger; 07-23-2011 at 09:45 AM.
    Best regard, -)iger-/iger
    If you are pleased with a solution mark your post SOLVED.

  5. #5
    Registered User
    Join Date
    07-22-2011
    Location
    Rock Island, Illinois
    MS-Off Ver
    Excel 2007
    Posts
    7

    Re: Auto copy & paste

    TigerTiger. Here is a sample file with three events.

    5 AA G456272534 AAA AAAAAAA AAAAAAAA AAAAAAA AAA AA

    15 BB HR667583TT BBB BBBBBBB BBBBBBBB BBBBBBB BBB BB

    20 CC SRT2675453 CCC CCCCCCC CCCCCCCC CCCCCCC CCC CC


    100 BB HR667583TT BBB BBBBBBB BBBBBBBB BBBBBBB BBB BB
    101 CC SRT2675453 CCC CCCCCCC CCCCCCCC CCCCCCC CCC CC
    102 AA G456272534 AAA AAAAAAA AAAAAAAA AAAAAAA AAA AA


    I enter HR667583TT in B100 and upon exiting B15 matches B100 so row 15 is copy-paste over row 100.
    I enter SRT2675453 in B101 and upon exiting B20 matches B101 so row 20 is copy-paste over row 101
    I enter G456272534 in B102 and upon exiting B5 matches B102 so row 5 is copy-paste over row 102.

    Obviously there are rows of data between the three I reference for this example, and the stack could be lengthy before it's deleted.
    I have thousands of rows above the resultant stack, so VBA seems the best.
    Last edited by clinet; 07-23-2011 at 09:19 PM. Reason: line up example colmns

  6. #6
    Valued Forum Contributor
    Join Date
    11-11-2008
    Location
    Euro
    MS-Off Ver
    2007, 2010
    Posts
    470

    Re: Auto copy & paste

    Try test the following code,
    Right click on sheet tab (the sheet in that you want auto input data) and select view code, then paste the following code in to

    Please Login or Register  to view this content.

    Or get the example from attached file
    Attached Files Attached Files

  7. #7
    Registered User
    Join Date
    07-22-2011
    Location
    Rock Island, Illinois
    MS-Off Ver
    Excel 2007
    Posts
    7

    Re: Auto copy & paste

    I think you've go the idea tigertiger, but your attached example isn't quite there. Regardless of what I enter in Bn under your rows I always get the row just above the row I enter data on... nothing further up. I've studied your logic, and it looks like your not scanning further up than -1 row. Am I missing seeing a loop that would scan further up than that... all the way to the top if necessary? Tomorrow (Monday) I will try your VBA in a copy of live data and see what happens. Thanks for being patient with a rooky.

  8. #8
    Valued Forum Contributor
    Join Date
    11-11-2008
    Location
    Euro
    MS-Off Ver
    2007, 2010
    Posts
    470

    Re: Auto copy & paste

    Quote Originally Posted by clinet View Post
    Am I missing seeing a loop that would scan further up than that... all the way to the top if necessary? .
    No, of course.

    In that code, it run only until meet the row matching the condition

  9. #9
    Valued Forum Contributor
    Join Date
    11-11-2008
    Location
    Euro
    MS-Off Ver
    2007, 2010
    Posts
    470

    Re: Auto copy & paste

    Try an alternative, it may be faster by using Find method (priority for the update record)
    Right click on sheet tab (the sheet in that you want auto input data) and select view code, then paste the following code in to

    Please Login or Register  to view this content.

  10. #10
    Registered User
    Join Date
    07-22-2011
    Location
    Rock Island, Illinois
    MS-Off Ver
    Excel 2007
    Posts
    7

    Re: Auto copy & paste

    Splendid tigertiger! Your latest code worked perfectly!

    Some day this rooky might be proficient like you

    Thank you. I will for sure add to your reputation.
    Last edited by clinet; 07-25-2011 at 09:35 AM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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