+ Reply to Thread
Results 1 to 8 of 8

For loop to past copied data at first blank row in another sheet

  1. #1
    Registered User
    Join Date
    01-25-2018
    Location
    Southeast
    MS-Off Ver
    2016
    Posts
    19

    For loop to past copied data at first blank row in another sheet

    Hi everyone,

    I have this loop setup to copy over data to sheet(2) if the value in C2:C6 is > 0. I need this to begin pasting it to the first blank row in sheet(2). this will need to keep the same selection size as (1,5) and place that data in the first blank row on sheet(2).

    Thank you


    Please Login or Register  to view this content.

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: For loop to past copied data at first blank row in another sheet

    Next available row...

    Please Login or Register  to view this content.
    Last edited by AlphaFrog; 02-07-2018 at 01:23 AM.
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  3. #3
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,610

    Re: For loop to past copied data at first blank row in another sheet

    Please Login or Register  to view this content.
    Ben Van Johnson

  4. #4
    Registered User
    Join Date
    01-25-2018
    Location
    Southeast
    MS-Off Ver
    2016
    Posts
    19

    Re: For loop to past copied data at first blank row in another sheet

    Alright! This is working, and I've modified it to my specific needs (see below).

    Please Login or Register  to view this content.
    Now I need to add a "feature" to the code. Have the source cell (E1) copied and pasted into the target cell only if an adjacent cell (A) on the same row is not blank. The adjacent cell is in the same sheet(2) as the target cell.

    In other words: only copy and paste the value in cell E1 (sheet1) into the next blank cell of Col F (sheet2) if the value in Col A (sheet2) of the same row is not blank. I'll post a screen shot of the destination cells below. These are in Sheet(2). I'm copying the name of a customer from the cell E1 in Sheet(1) to each cell in the G column if there is an item number present in Col A.

    VBAtarget.PNG

  5. #5
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,522

    Re: For loop to past copied data at first blank row in another sheet

    Re: For Each c In Sheets(1).Range("E1")
    How many c's (=Ranges) do you visualize to have in a single cell (E1)?
    Maybe add a workbook with a before and after. Pictures are very difficult to try a macro on

  6. #6
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,610

    Re: For loop to past copied data at first blank row in another sheet

    ...only copy and paste the value in cell E2 (sheet1) into the next blank cell of Col F (sheet2) if the value in Col A (sheet2) of the same row is not blank....
    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    01-25-2018
    Location
    Southeast
    MS-Off Ver
    2016
    Posts
    19

    Re: For loop to past copied data at first blank row in another sheet

    Pronto, thank you!

    I see the logic you've laid out but implemented the code and it continues to paste the E1 string to column F in sheet(2) indefinietly. I looked at the code with my novice eyes and found what I think to be the issue. I'll attempt to highlight it below:

    Please Login or Register  to view this content.
    If the code is looking to "c.Row" then isnt it looking to the row that cell E1 on Sheet(1) is located? Since c was = sheets(1).Range("E1"). It would need to look into sheet(2) and the cell in Col "A" of the first blank row (destROW).

    I tried to change the code to look for that value but only received compile errors

  8. #8
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,610

    Re: For loop to past copied data at first blank row in another sheet

    If you only want to paste if Sheet(2), AdestROW is > 0, then:
    Please Login or Register  to view this content.

+ 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. If adjacent cell contains data the past todays date, beginning at the first blank row
    By RaDoubleD in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-07-2018, 10:16 AM
  2. VBA Code to delete blank cells from copied data
    By Jes1397 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 04-29-2017, 01:42 PM
  3. [SOLVED] VBA automatically Cut and Past (cut and past it into the different work sheet)
    By seifeddine87 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-31-2016, 07:08 PM
  4. [SOLVED] Macro will not move copied data to next blank row?
    By DG370 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 01-15-2013, 10:54 AM
  5. Hello, need help - Vba code for INSERT (not past) copied row... Happy holiday
    By zeko90 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-18-2012, 10:53 AM
  6. [SOLVED] Seach for data from one sheet to another sheet and copy past adjacent columns
    By mahtabshaikh in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-19-2012, 10:19 AM
  7. loop past blank cell
    By Zrx in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 10-19-2011, 08:20 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