+ Reply to Thread
Results 1 to 9 of 9

VBA to copy row (or selected cells) from one sheet to another

  1. #1
    Registered User
    Join Date
    05-20-2020
    Location
    Edinburgh, Scotland
    MS-Off Ver
    Office Pro Plus 2013
    Posts
    19

    VBA to copy row (or selected cells) from one sheet to another

    Hi folks,

    Hopefully someone can help me please?

    I've created a workbook with different tabs - including Risk Register and Checkpoint. What I'm trying to do is when the user completes the Risk Register and inputs a Y to "Send to checkpoint" the row copies over into the Checkpoint. I did have it set with a formula but it meant if people had a Y followed by N then there would be empty rows on the Checkpoint, so I think VBA is the only way to copy it over...I just can't figure it out. Does anyone know how it do it please?

    I've tried the following but it's getting a runtime.

    Please Login or Register  to view this content.
    Example attached.

    Thanks very much
    Attached Files Attached Files
    Last edited by A.Walloper; 08-04-2020 at 09:06 AM.

  2. #2
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,890

    Re: VBA to copy row (or selected cells) from one sheet to another

    Administrative Note:

    Welcome to the forum.

    We would very much like to help you with your query, however you need to include code tags around your code.

    Please take a moment to add the tags. Posting code between tags makes your code much easier to read and copy for testing, and it also maintains VBA formatting.

    Please see Forum Rule #2 about code tags and adjust accordingly. Click on Edit to open your post, then highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here

    (Note: this change is not optional. No help to be offered until this moderation request has been fulfilled.)
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  3. #3
    Registered User
    Join Date
    05-20-2020
    Location
    Edinburgh, Scotland
    MS-Off Ver
    Office Pro Plus 2013
    Posts
    19

    Re: VBA to copy row (or selected cells) from one sheet to another

    Whoops - sorry Alan. Updated

  4. #4
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,890

    Re: VBA to copy row (or selected cells) from one sheet to another

    Use a Worksheet Change Event and place it in the Risk WS

    Please Login or Register  to view this content.

  5. #5
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,623

    Re: VBA to copy row (or selected cells) from one sheet to another

    Let me address the issue of Runtime error:

    May be the issue is because you use "printing" quotation marks?

    like:

    Please Login or Register  to view this content.
    instead of

    Please Login or Register  to view this content.
    Check the attached file.

    PS. Note that Risks have to be active sheet before you start the code. otherwise results will be unpredictible.
    Attached Files Attached Files
    Best Regards,

    Kaper

  6. #6
    Registered User
    Join Date
    05-20-2020
    Location
    Edinburgh, Scotland
    MS-Off Ver
    Office Pro Plus 2013
    Posts
    19

    Re: VBA to copy row (or selected cells) from one sheet to another

    Quote Originally Posted by Kaper View Post
    Let me address the issue of Runtime error:

    May be the issue is because you use "printing" quotation marks?

    like:

    Please Login or Register  to view this content.
    instead of

    Please Login or Register  to view this content.
    Check the attached file.

    PS. Note that Risks have to be active sheet before you start the code. otherwise results will be unpredictible.
    Thanks very much!

    When I run it, it works, but if I run it again it's still carrying over the top line (row 3) even though I've selected N for sending to checkpoint. Any ideas?

  7. #7
    Registered User
    Join Date
    05-20-2020
    Location
    Edinburgh, Scotland
    MS-Off Ver
    Office Pro Plus 2013
    Posts
    19

    Re: VBA to copy row (or selected cells) from one sheet to another

    Quote Originally Posted by alansidman View Post
    Use a Worksheet Change Event and place it in the Risk WS

    Please Login or Register  to view this content.
    Thanks Alan, I tried this but couldn't get it to work at all - I'm a beginner with VBA so wasn't too sure how to actually activate it.

    Also - Steamboat Springs, that place is awesome - lucky you!

  8. #8
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,890

    Re: VBA to copy row (or selected cells) from one sheet to another

    Here's your file with my code embedded.
    Attached Files Attached Files

  9. #9
    Registered User
    Join Date
    05-20-2020
    Location
    Edinburgh, Scotland
    MS-Off Ver
    Office Pro Plus 2013
    Posts
    19

    Re: VBA to copy row (or selected cells) from one sheet to another

    Alan, thank you so much - that's fantastic!

    Is there a way to get it to overwrite the lines, instead of adding at the bottom?

+ 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 Selected cells to another sheet
    By COURTTROOPER in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 11-28-2018, 05:33 PM
  2. VBA-Copy selected cells and paste under table on another sheet
    By jsherwood in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-05-2018, 04:46 AM
  3. Replies: 8
    Last Post: 09-03-2015, 08:43 AM
  4. [SOLVED] Copy Value from selected cells to a new workbook sheet
    By pipoliveira in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-11-2013, 11:33 AM
  5. copy selected cells to new sheet
    By sad212 in forum Excel General
    Replies: 0
    Last Post: 06-11-2012, 02:45 PM
  6. copy selected cells to new sheet in a row using macro
    By cvsuryam in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-04-2011, 04:11 PM
  7. Replies: 2
    Last Post: 08-08-2006, 12:50 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