+ Reply to Thread
Results 1 to 20 of 20

Complicated copy & paste macro

  1. #1
    Valued Forum Contributor
    Join Date
    03-03-2009
    Location
    UK
    MS-Off Ver
    MS365 Subscription Excel for Mac
    Posts
    1,017

    Complicated copy & paste macro

    On Sheet2 in column B from row 3 downwards there are two words. These words can vary but it will always be two words. So from B3 downwards the cell would have to contain for example either "Test" or "Active". As I said, the two words can be anything. The column will always be sorted from A to Z so what I need is for a macro to copy from B3 down as far as Bx and paste this into sheet 1 in A1. And then to copy from B(x+1) down as far as B55 and paste it into sheet 1 in B1.

  2. #2
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: Complicated copy & paste macro

    Would be easier to help if you attach a workbook, and show what your expected outcome looks like.
    let Source = #table({"Question","Thread", "User"},{{"Answered","Mark Solved", "Add Reputation"}}) in Source

    If I give you Power Query (Get & Transform Data) code, and you don't know what to do with it, then CLICK HERE

    Walking the tightrope between genius and eejit...

  3. #3
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: Complicated copy & paste macro

    Hi, ScabbyDog,

    can you elaborate on Bx and on B(x+1)/B55 or attach a sample to make clear? The situation you made up counts for 53 rows, and I donīt see the difference between the pasting into Column A and Column B from the same range.

    Ciao,
    Holger
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

  4. #4
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Complicated copy & paste macro

    Maybe:

    Please Login or Register  to view this content.

  5. #5
    Valued Forum Contributor
    Join Date
    03-03-2009
    Location
    UK
    MS-Off Ver
    MS365 Subscription Excel for Mac
    Posts
    1,017

    Re: Complicated copy & paste macro

    Quote Originally Posted by JOHN H. DAVIS View Post
    Maybe:

    Please Login or Register  to view this content.
    Problem with this John is that it will be different words all the same and not always Test and Active.

  6. #6
    Valued Forum Contributor
    Join Date
    03-03-2009
    Location
    UK
    MS-Off Ver
    MS365 Subscription Excel for Mac
    Posts
    1,017

    Re: Complicated copy & paste macro

    Quote Originally Posted by HaHoBe View Post
    Hi, ScabbyDog,

    can you elaborate on Bx and on B(x+1)/B55 or attach a sample to make clear? The situation you made up counts for 53 rows, and I donīt see the difference between the pasting into Column A and Column B from the same range.

    Ciao,
    Holger
    Bx is the last cell where the first word is used. So if cells B3 to B23 for example all contained LOVE then Bx would be cell B23

  7. #7
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Complicated copy & paste macro

    What determines which two words to use?

  8. #8
    Valued Forum Contributor
    Join Date
    03-03-2009
    Location
    UK
    MS-Off Ver
    MS365 Subscription Excel for Mac
    Posts
    1,017

    Re: Complicated copy & paste macro

    They are imported from another sheet. They will always be different words each time the macro is run, but it will only ever be two unique words.

  9. #9
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Complicated copy & paste macro

    Are they imported to a certain range?

  10. #10
    Valued Forum Contributor
    Join Date
    03-03-2009
    Location
    UK
    MS-Off Ver
    MS365 Subscription Excel for Mac
    Posts
    1,017

    Re: Complicated copy & paste macro

    Yeah in range B3:B55 but they will also be data sorted so the first say 20 cells could be the first word and the next 15 the second word and the remaining cells in the range blank. Or it could be the first 25 cells the first word, the next 15 cells the 2nd word, and the remaining cells blank, etc etc etc

  11. #11
    Valued Forum Contributor
    Join Date
    03-03-2009
    Location
    UK
    MS-Off Ver
    MS365 Subscription Excel for Mac
    Posts
    1,017

    Re: Complicated copy & paste macro

    Another way of wording what I want would be:

    I want to copy from B3 down as far to where the cell below it does not equal B3 and paste it to sheet 1 in cell A1. And then, copy the cell that does not equal B3 down as far as B55 and paste it into sheet1 cell B1

  12. #12
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Complicated copy & paste macro

    In order to use this you have to assume that the top value (B3) is one of the words, and the bottom value (B55) is the other. Can't be sure though, since there are other words that may end up in those positions based on your sort?

    Please Login or Register  to view this content.

  13. #13
    Valued Forum Contributor
    Join Date
    03-03-2009
    Location
    UK
    MS-Off Ver
    MS365 Subscription Excel for Mac
    Posts
    1,017

    Re: Complicated copy & paste macro

    B3 will always be the first word. B55 won't always be the 2nd word though. There will only ever be two words in the range B3:B55.

  14. #14
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Complicated copy & paste macro

    Quote Originally Posted by ScabbyDog View Post
    Another way of wording what I want would be:

    I want to copy from B3 down as far to where the cell below it does not equal B3 and paste it to sheet 1 in cell A1. And then, copy the cell that does not equal B3 down as far as B55 and paste it into sheet1 cell B1
    Untested - Maybe:

    Please Login or Register  to view this content.

  15. #15
    Valued Forum Contributor
    Join Date
    03-03-2009
    Location
    UK
    MS-Off Ver
    MS365 Subscription Excel for Mac
    Posts
    1,017

    Re: Complicated copy & paste macro

    That works, BUT it always fails to copy the very last cell where the first word exists. So if B20=Test and B21=OtherWord it would not copy that last line.

  16. #16
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Complicated copy & paste macro

    Maybe:

    Please Login or Register  to view this content.

  17. #17
    Valued Forum Contributor
    Join Date
    03-03-2009
    Location
    UK
    MS-Off Ver
    MS365 Subscription Excel for Mac
    Posts
    1,017

    Re: Complicated copy & paste macro

    Also, how would I alter it so that it starts pasting in B28 onwards for the second loop? That would be it solved then.
    Last edited by ScabbyDog; 12-11-2013 at 03:03 PM.

  18. #18
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Complicated copy & paste macro

    Maybe:

    Please Login or Register  to view this content.

  19. #19
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: Complicated copy & paste macro

    Hi, ScabbyDog,

    maybe like this:
    Please Login or Register  to view this content.
    Ciao,
    Holger

  20. #20
    Valued Forum Contributor
    Join Date
    03-03-2009
    Location
    UK
    MS-Off Ver
    MS365 Subscription Excel for Mac
    Posts
    1,017

    Re: Complicated copy & paste macro

    Thanks guys. Working a treat now.

+ 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. Copy/Paste Complicated Table Between Sheet
    By dompoma in forum Excel General
    Replies: 4
    Last Post: 04-20-2013, 02:57 PM
  2. [SOLVED] Find a number then copy/paste (complicated)
    By ScabbyDog in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 02-25-2013, 05:36 PM
  3. [SOLVED] Simple copy and paste macro- Paste special help needed.
    By hernancrespo in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-20-2012, 07:02 AM
  4. 2 Macro's: only vertical copy/paste action and copy-paste 14 columns to the right.
    By vdongen in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-08-2010, 10:34 AM
  5. [SOLVED] Copy and Paste macro needs to paste to a changing cell reference
    By loulou in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-24-2005, 07:06 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