+ Reply to Thread
Results 1 to 2 of 2

VBA code to copy cell values to the next blank row in another sheet (all the same row)

  1. #1
    Registered User
    Join Date
    04-18-2013
    Location
    Mississauga, Ontario Canada
    MS-Off Ver
    Excel 2010
    Posts
    2

    Talking VBA code to copy cell values to the next blank row in another sheet (all the same row)

    I don't really know how to write VBA codes. I just look for them in the forums such as this then apply them.
    I have searched for the solution to my problem but couldn't find the specific answer to my issue.
    I created a macro to copy cell values from an input sheet for a purchase order (PO) to paste to a PO log sheet. I tweaked the code so that it copies to the next blank row in the log sheet. however, some cells in the input sheet may not always be filled by the user. So the issue is that, when a cell value finally exists for a particular cell, instead of it pasting in the same row as the other records for that same PO., it gets pasted on the next blank row for that field column.
    For example:
    What it should do:
    Entry 1
    Input sheet: Copy B2 = May 1, C2 = TEST, D2 = blank, B3 = 100
    Log sheet: Paste B2 = May 1, C2 = TEST, E2 = blank and G2 = 100
    Entry 2
    IInput sheet: Copy B2 = May 3, C2 = TEST 1, D2 = 200, B3 = 50
    Log sheet: Paste B3 = May 3, C3 = TEST 1, E3 = 200 and G3 = 50

    What is happening for entry 2:
    IInput sheet: Copy B2 = May 3, C2 = TEST 1, D2 = 200, B3 = 50
    Log sheet: Paste B3 = May 3, C3 = TEST 1,E2 = 200 and G3 = 50

    YOUR HELP IS MUCH APPRECIATED.

    Here is the code (I had to delete some lines because it was too long):



    Please Login or Register  to view this content.
    Last edited by rarias; 05-16-2013 at 05:07 PM.

  2. #2
    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,197

    Re: VBA code to copy cell values to the next blank row in another sheet (all the same row)

    Hi, rarias,

    as you get the last filled row for every column itīs not so surprising I think.

    Just check the row to write to once and then fill all data and augment the value for teh next line to be copied (maybe you could even pass a range instead of sinlge cells). Just a small example assuming that Column A on the log sheet is thoroughly filled with data (assuming a date time stamp there):
    Please Login or Register  to view this content.
    You may even use two arrays to hold the characters for the columns and loop through these arrays.

    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

+ 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