+ Reply to Thread
Results 1 to 5 of 5

Move Row to Another Sheet & Delete From Original Data

  1. #1
    Registered User
    Join Date
    10-05-2023
    Location
    Worksop, England
    MS-Off Ver
    Office 365
    Posts
    3

    Move Row to Another Sheet & Delete From Original Data

    Health and safety.xlsm

    Hi, I've been trying to set up a VBA code which will automatically move the entire row in the worksheet "H&S Incidents Open" into the worksheet "H&S Incidents Closed" based on the value in column "J", once the value "Closed" is selected.
    The macro works when I run it and moves the row into the correct worksheet, but it will only place one row in the Closed worksheet and every new row which needs moving replaces that information rather than going below. Would someone be able to advise me on where I'm going wrong.

  2. #2
    Forum Contributor
    Join Date
    06-14-2016
    Location
    Brookland, Arkansas
    MS-Off Ver
    2007,2021
    Posts
    129

    Re: Move Row to Another Sheet & Delete From Original Data

    Hi Holly,

    Try replacing:
    sourceSheet.Rows(i).Copy Destination:=targetSheet.Cells(targetSheet.Rows.Count, "A").End(xlUp).Offset(1)

    With:
    sourceSheet.Rows(i).Copy Destination:=targetSheet.Cells(targetSheet.Rows.Count, "B").End(xlUp).Offset(1, -1)

    From my understanding of your post, this would fix the problem you are having.
    Who needs a life when you have Excel.

  3. #3
    Registered User
    Join Date
    10-05-2023
    Location
    Worksop, England
    MS-Off Ver
    Office 365
    Posts
    3

    Re: Move Row to Another Sheet & Delete From Original Data

    Thank you very much that worked great. Do you know if there is a way for me to have it running continuously rather than having to manually run it?

  4. #4
    Forum Contributor
    Join Date
    06-14-2016
    Location
    Brookland, Arkansas
    MS-Off Ver
    2007,2021
    Posts
    129

    Re: Move Row to Another Sheet & Delete From Original Data

    Personally, I am not aware of how to make it run continuously. I am sure someone else here may know how to do that. The closest thing I can think of is to have a Worksheet_SelectionChange trigger, that runs the module. (Link To Read)

    There may be other triggers that better do what you want.

  5. #5
    Forum Expert Greg M's Avatar
    Join Date
    08-16-2007
    Location
    Dublin. Ireland
    MS-Off Ver
    Office 2016
    Posts
    4,481

    Re: Move Row to Another Sheet & Delete From Original Data

    Hi there,

    In view of the fact that you're stepping through the rows from top to bottom (rather than from bottom to top), I doubt that the code will correctly move all of the required rows.

    Have a look at the attached version of your workbook and see if it does what you need - it uses the following code:

    Please Login or Register  to view this content.
    The highlighted values may be changed to suit your requirements.


    Hope this helps.

    Regards,

    Greg M
    Attached Files Attached Files
    Last edited by Greg M; 10-05-2023 at 02:36 PM. Reason: Typo corrected

+ 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. Move data to master sheet the delete original data
    By ROP934R in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-18-2022, 03:15 PM
  2. worksheet change - cut row, move to desired sheet, delete original row
    By dsmith616 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 09-08-2015, 09:25 PM
  3. [SOLVED] Delete both Original and duplicate rows off data in 1 column for entire sheet
    By Caraexcel in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-01-2014, 01:33 AM
  4. [SOLVED] Move entire row from one sheet to another based on cell value & delete the original row
    By ceciliacrawford in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 01-08-2014, 03:12 AM
  5. [SOLVED] VBA move entry on condition and delete original Problem
    By Steveluba in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-24-2013, 12:16 PM
  6. move files to another folder delete original
    By D_Rennie in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 09-09-2009, 02:50 AM
  7. Filter records, paste into a different sheet, delete rows from original sheet.
    By gloworm1973 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-28-2009, 05:24 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