+ Reply to Thread
Results 1 to 11 of 11

Copy/Paste to next Cell if A:A <> 1

  1. #1
    Forum Contributor
    Join Date
    08-14-2012
    Location
    USA
    MS-Off Ver
    Excel 2007, MS 365 (Windows 10 Pro 64-bit)
    Posts
    818

    Copy/Paste to next Cell if A:A <> 1

    Hello All,
    I need help to COPY/PASTE if value in COLUMN A:A <> 1. Please see sample attached.

    Regards,
    tt3
    Attached Files Attached Files
    Last edited by tuongtu3; 12-23-2015 at 04:09 AM. Reason: SOLVED

  2. #2
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,956

    Re: Copy/Paste to next Cell if A:A <> 1

    Copy what? Will the 1's always be contiguous as in the example?

    As best I can tell, you take the last row that doesn't have a 1 (row 8) and copy and paste it to the end of the row above it (row 7). Then you take the row above it (row 7 in the example) and paste it to the end of the row above it (row 6 in the example). You stop appending because the row above it (row 5) has a 1 in column A.

    In theory you could keep copying and pasting until you run out of rows.

    Have I described what you want sufficiently?

  3. #3
    Forum Contributor
    Join Date
    08-14-2012
    Location
    USA
    MS-Off Ver
    Excel 2007, MS 365 (Windows 10 Pro 64-bit)
    Posts
    818

    Re: Copy/Paste to next Cell if A:A <> 1

    Hi dflak,

    Will the 1's always be contiguous as in the example? <=== YES
    and it stop at row 5 becuase its has a 1 in column A.

    Regards,
    tt3

  4. #4
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,956

    Re: Copy/Paste to next Cell if A:A <> 1

    Here is the "magic"
    Please Login or Register  to view this content.
    Attached Files Attached Files

  5. #5
    Forum Expert Alf's Avatar
    Join Date
    03-13-2004
    Location
    Gothenburg/Mullsjoe, Sweden
    MS-Off Ver
    Excel 2019 and not sure I like it
    Posts
    4,784

    Re: Copy/Paste to next Cell if A:A <> 1

    A slightly different approach.

    Please Login or Register  to view this content.
    Alf

  6. #6
    Forum Expert Alf's Avatar
    Join Date
    03-13-2004
    Location
    Gothenburg/Mullsjoe, Sweden
    MS-Off Ver
    Excel 2019 and not sure I like it
    Posts
    4,784

    Re: Copy/Paste to next Cell if A:A <> 1

    Hi tt3

    Thanks for feedback and rep.

    My macro is "build" on the assumption that column A either contains 1 or nothing whereas dflak's code checks if the value in column A really is 1. So if your uploaded file had 2 in cell A6 my code would only copy values in row 8 to row 7 where dflak's code would copy row 7 and 8 to row 6 and row 8 to row 7. As I'm not really sure what you wanted I thought it was best to point out the differences so you can select the code that suit your need best.

    Hi deflak
    Liked the way you included comments in you code, a thing I shall try to adapt to as well in the future. By the way I think you forgot to add a "Application.CutCopyMode = False" at the end of your code.

    Alf

  7. #7
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,956

    Re: Copy/Paste to next Cell if A:A <> 1

    I've been coding since the 1980's. I've gotten into the habit of writing comments. In fact, I start with the comments tell me what I have to do and then fill in with code.

  8. #8
    Forum Contributor
    Join Date
    08-14-2012
    Location
    USA
    MS-Off Ver
    Excel 2007, MS 365 (Windows 10 Pro 64-bit)
    Posts
    818

    Re: Copy/Paste to next Cell if A:A <> 1

    Hi Alf,
    Both codes are very good. First I modified code from "dflak" so code can loop and stop at cell A1 to find "1". Can you modify your code to do so (loop up to Cell A1) and please note that I also need to copy from BLANK CELL to upper CELL contain "1" or ANY other number. Please see sample.

    Regards,
    tt3
    Attached Files Attached Files

  9. #9
    Forum Expert Alf's Avatar
    Join Date
    03-13-2004
    Location
    Gothenburg/Mullsjoe, Sweden
    MS-Off Ver
    Excel 2019 and not sure I like it
    Posts
    4,784

    Re: Copy/Paste to next Cell if A:A <> 1

    Test this code and see if it works the way you wish.

    Please Login or Register  to view this content.
    Alf

    Ps Merry Christmas

  10. #10
    Forum Contributor
    Join Date
    08-14-2012
    Location
    USA
    MS-Off Ver
    Excel 2007, MS 365 (Windows 10 Pro 64-bit)
    Posts
    818

    Re: Copy/Paste to next Cell if A:A <> 1

    Hi Alf,
    That's perfect and thank you very much for your time.

    Regards,
    tt3
    Ps Merry Christmas

  11. #11
    Forum Expert Alf's Avatar
    Join Date
    03-13-2004
    Location
    Gothenburg/Mullsjoe, Sweden
    MS-Off Ver
    Excel 2019 and not sure I like it
    Posts
    4,784

    Re: Copy/Paste to next Cell if A:A <> 1

    Thanks for feedback and rep.

    Regards

    Alf

+ 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 data using checkbox-clear when unchckd & multiple selections paste in next cell
    By Staceymcw in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 12-02-2015, 12:09 AM
  2. Copy and Paste w/ Paste Destination determined by Cell Value
    By jeremy9er7 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-10-2014, 10:42 AM
  3. Replies: 6
    Last Post: 07-27-2013, 09:02 AM
  4. Replies: 8
    Last Post: 07-08-2013, 06:03 AM
  5. [SOLVED] Copy cell A1 and paste value into B1 if B1 has content, paste to B2...etc
    By mhopke in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-09-2012, 09:39 PM
  6. How to select cell C1, copy paste then C2, copy paste then C3 etc
    By s45yth in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-07-2011, 07:15 AM
  7. 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