How to Move Row to Another Sheet Based on Cell Value in Excel

Microsoft Excel is a powerful software. We can perform numerous operations on our datasets using Excel tools and features. There are many default Excel Functions that we can use to create formulas. Many educational institutions and business companies use Excel files to store valuable data. Sometimes, we need to move rows based on particular cell values from one Excel sheet to another. In those cases, moving the rows manually is a tiresome process and also time-consuming. This article will show you 2 easy ways in Excel to Move a Row to Another Sheet Based on Cell Value.


How to Move Row to Another Sheet Based on Cell Value in Excel: 2 Easy Ways

Often we have to move or copy rows based on cell value to different worksheets for various purposes. The cell value can be in any column. To illustrate, we’ll use a sample dataset as an example. For instance, in the following dataset, we have multiple products in column C. Here, we’ll move the rows that contain the product Cable to another sheet.


1. Apply Filter Feature in Excel to Move Row to Another Sheet Based on Cell Value

In our first method, we’ll apply the Filter feature to move a row to another sheet based on cell value. Therefore, follow the steps below to perform the task.

STEPS:

  • First, click the Product header (cell C4).
  • Then, go to Home ➤ Editing ➤ Sort & Filter ➤ Filter.

Apply Filter Feature in Excel to Move Row to Another Sheet Based on Cell Value

  • Consequently, you’ll see drop-down icons beside every header.
  • After that, select the drop-down icon beside the Product header.
  • There, check the box for Cable only.
  • Press OK.

Apply Filter Feature in Excel to Move Row to Another Sheet Based on Cell Value

  • Thus, it’ll return only the rows that contain the Cable.
  • See the below picture where the filtered result is demonstrated.
  • Now, select the rows and copy them by pressing the Ctrl and C keys.

Apply Filter Feature in Excel to Move Row to Another Sheet Based on Cell Value

  • Next, go to the desired sheet.
  • Select any cell where you want to paste the rows.
  • Press the Ctrl and V keys.
  • Hence, you’ll see the following outcome.

Apply Filter Feature in Excel to Move Row to Another Sheet Based on Cell Value

Read More: Move Row to Bottom in Excel If Cell Contains a Value


2. Move Row to Another Sheet Based on Cell Value with Excel VBA

Moreover, Excel VBA is an amazing program by which we can carry out numerous operations. In our last method, we’ll execute VBA codes to move rows to another sheet based on cell value. So, learn the following process.


2.1 Deleting Original

Here, we’ll move rows to another sheet and delete the original ones at the same time.

STEPS:

  • Firstly, go to Developer ➤ Visual Basic.

Move Row to Another Sheet Based on Cell Value with Excel VBA

  • As a result, the VBA window will pop out.
  • Subsequently, click Insert ➤ Module.
  • Thus, you’ll get a Module window.
  • There, paste the following code.
Sub MoveRow_DeleteOriginal()
Dim rg As Range
Dim xc As Range
Dim p As Long
Dim q As Long
Dim r As Long
p = Worksheets("VBA delete original").UsedRange.Rows.Count
q = Worksheets("Sheet1").UsedRange.Rows.Count
If q = 1 Then
If Application.WorksheetFunction.CountA(Worksheets("Sheet1").UsedRange) = 0 Then q = 0
End If
Set rg = Worksheets("VBA delete original").Range("C1:C" & p)
On Error Resume Next
Application.ScreenUpdating = False
 For r = 1 To rg.Count
 If CStr(rg(r).Value) = "Cable" Then
 rg(r).EntireRow.Copy Destination:=Worksheets("Sheet1").Range("A" & q + 1)
 rg(r).EntireRow.Delete
 If CStr(rg(r).Value) = "Cable" Then
 r = r - 1
 End If
 q = q + 1
End If
Next
Application.ScreenUpdating = True
End Sub

Move Row to Another Sheet Based on Cell Value with Excel VBA

NOTE: In the code, make necessary changes. Input your original sheet name instead of ‘VBA delete original’. Then, type your new sheet name instead of Sheet1 where you’ll move the rows. Next, edit the range C1:C to meet your required column where the cell value will be. Finally, replace the Cable with your desired cell value.
  • Save the file and press the F5 key to run the code.
  • Consequently, the rows with Cable will get deleted.
  • Look at the figure below where the rows with Cable are absent.

Move Row to Another Sheet Based on Cell Value with Excel VBA

  • Lastly, in Sheet1, you’ll see the required rows.

Move Row to Another Sheet Based on Cell Value with Excel VBA


2.2 Keeping Original

However, we can also keep the original data if we wish. Learn the process to make the changes in the code.

STEPS:

  • First of all, select Developer ➤ Visual Basic.
  • Then, click Insert ➤ Module.
  • As a result, the Module window will appear.
  • Now, copy the below code and paste it there.
Sub MoveRow_KeepOriginal()
Dim rg As Range
Dim xc As Range
Dim p As Long
Dim q As Long
Dim r As Long
p = Worksheets("VBA keep original").UsedRange.Rows.Count
q = Worksheets("Sheet2").UsedRange.Rows.Count
If q = 1 Then
If Application.WorksheetFunction.CountA(Worksheets("Sheet2").UsedRange) = 0 Then q = 0
End If
Set rg = Worksheets("VBA keep original").Range("C1:C10" & p)
On Error Resume Next
Application.ScreenUpdating = False
 For r = 1 To rg.Count
 If CStr(rg(r).Value) = "Cable" Then
 rg(r).EntireRow.Copy Destination:=Worksheets("Sheet2").Range("A" & q + 1)
 q = q + 1
End If
Next
Application.ScreenUpdating = True
End Sub

NOTE: In the code, input your original sheet name instead of ‘VBA keep original’. Then, type your new sheet name instead of Sheet2 where you’ll move the rows. Next, edit the range C1:C10 to meet your required column where the cell value will be. Finally, replace the Cable with your desired cell value.
  • Next, press the F5 key to run the code.
  • See the below figure where the rows with Cable are present.

  • At the same time, it’ll return the rows with Cable in Sheet2.

Read More: How to Move Rows in Excel Without Replacing


Download Practice Workbook

Download the following workbook to practice by yourself.


Conclusion

Henceforth, you will be able to use the above-described methods in Excel to Move a Row to Another Sheet Based on Cell Value. Keep using them and let us know if you have more ways to do the task. Don’t forget to drop comments, suggestions, or queries if you have any in the comment section below.


Related Articles


<< Go Back to Move Rows | Rows in Excel | Learn Excel

Get FREE Advanced Excel Exercises with Solutions!
Aung Shine
Aung Shine

Aung Shine completed his bachelor’s in Electrical and Electronics Engineering from Bangladesh University of Engineering and Technology. It has been almost 2 years since he joined SOFTEKO and actively working on the ExcelDemy project. Currently he works as a Team Leader where he guides his team members to create technical content. He has published 150+ articles and reviewed 50+ articles. He has also solved various user problems before. He has interests in Data Analysis, Power Query, Advanced Excel,... Read Full Bio

25 Comments
  1. Hi,

    I really need a code to move a line from one sheet to another, this code above only deletes the row and its not pulling through to the other sheet?
    Can someone help?

    • Hello ASHLEIGH,
      Thank you for your question. We’re sorry to hear that you’re facing difficulties with the VBA code. In fact, the ExcelDemy team has tested the Excel file and the code with other workbooks following your comment and the code appears to be working correctly.
      However, you can check the following 4 steps.
      1. You can choose any of the two formats according to your need from Method-2. Additionally, read the Notes given after each code. This will help you to understand the code properly.
      2. You must create a worksheet where you want to move the filtered rows.
      3. Set the Input Worksheet and Destination Worksheet names properly with the Range.
      4. In this code, we have selected Cable as filter criteria. So, the rows containing Cable within the given Range will be deleted and it will be moved to your Destination Workbook. So, make sure you have provided the criteria according to your dataset.
      I hope this will solve your issue. If you still face problems, please feel free to comment again or send your workbook through e-mail so that I can check the issue.

  2. Hi, if I want to use different values and different sheets, can I use one module for this? For example: if a cell contains value A, then the row moves from sheet 1 to sheet 2, if it contains value B, then the row moves from sheet 1 to sheet 3. How do I implement this into the code?

    • Reply Lutfor Rahman Shimanto
      Lutfor Rahman Shimanto Apr 13, 2023 at 11:18 AM

      Hello CAR

      Thank you for reaching out to us on our website. You can use a single module to move rows between sheets based on various values. You may do this by using an IF statement inside a FOR loop that iterates through the rows in Sheet1, verifies the value, and then moves the entire row to the proper destination sheet based on the value. The intended code is given below.

      
      Sub MoveRowsInSheetsBasedOnValues()
      
          Dim wsSource As Worksheet, wsDest As Worksheet
          Dim i As Long, lastRow As Long, destRow As Long
          
          Set wsSource = ThisWorkbook.Worksheets("Sheet1")
          lastRow = wsSource.Cells(wsSource.Rows.Count, "B").End(xlUp).Row
          
          Set wsDest = ThisWorkbook.Worksheets("Sheet2")
          destRow = 1
          
          For i = 1 To lastRow
              If wsSource.Cells(i, "B").Value = "A" Then
                  wsSource.Rows(i).Copy wsDest.Rows(destRow)
                  destRow = wsDest.Cells(wsDest.Rows.Count, "B").End(xlUp).Row + 1
              End If
          Next i
          
          Set wsDest = ThisWorkbook.Worksheets("Sheet3")
          destRow = 1
          
          For i = 1 To lastRow
              If wsSource.Cells(i, "B").Value = "B" Then
                  wsSource.Rows(i).Copy wsDest.Rows(destRow)
                  destRow = wsDest.Cells(wsDest.Rows.Count, "B").End(xlUp).Row + 1
              End If
          Next i
          
      End Sub
      

      Regards
      Lutfor Rahman Shimanto

      • Hi again,
        I finally had time to update the code in my spreadsheet, but it doesn’t seem to work. I probably made a mistake somewhere, do you think you could check this code to see if i did something wrong?

        The value that needs to be selected is in column I, from row 3.

        There are multiple values in a dropdown menu in this column, of which 4 values are used in the code:

        If value “1. Cancelled”, then move to sheet “Cancelled Rejected Proposals”
        If value “2. Rejected”, then move to sheet “Cancelled Rejected Proposals”
        If value “9. Projectnumber assigned”, then move to sheet “Projects”
        If value “10. Finished”, then move to sheet “Finished Projects”

        The move from one sheet to another should also be as of row 3, since the first two rows are for titles.

        I hope you can help, thank you so much in advance!

        Sub MoveRowsInSheetsBasedOnValues()

        Dim wsSource As Worksheet, wsDest As Worksheet
        Dim i As Long, lastRow As Long, destRow As Long

        Set wsSource = ThisWorkbook.Worksheets(“Acquisition”)
        lastRow = wsSource.Cells(wsSource.Rows.Count, “I”).End(xlUp).Row

        Set wsDest = ThisWorkbook.Worksheets(“Projects”)
        destRow = 1

        For i = 1 To lastRow
        If wsSource.Cells(i, “I”).Value = “9. Projectnumber assigned” Then
        wsSource.Rows(i).Copy wsDest.Rows(destRow)
        destRow = wsDest.Cells(wsDest.Rows.Count, “I”).End(xlUp).Row + 1
        End If
        Next i

        Set wsDest = ThisWorkbook.Worksheets(“Finished Projects”)
        destRow = 1

        For i = 1 To lastRow
        If wsSource.Cells(i, “I”).Value = “10. Finished” Then
        wsSource.Rows(i).Copy wsDest.Rows(destRow)
        destRow = wsDest.Cells(wsDest.Rows.Count, “I”).End(xlUp).Row + 1
        End If
        Next i

        Set wsDest = ThisWorkbook.Worksheets(“Cancelled Rejected Proposals”)
        destRow = 1

        For i = 1 To lastRow
        If wsSource.Cells(i, “I”).Value = “1. Cancelled” Then
        wsSource.Rows(i).Copy wsDest.Rows(destRow)
        destRow = wsDest.Cells(wsDest.Rows.Count, “I”).End(xlUp).Row + 1
        End If
        Next i

        Set wsDest = ThisWorkbook.Worksheets(“Cancelled Rejected Proposals”)
        destRow = 1

        For i = 1 To lastRow
        If wsSource.Cells(i, “I”).Value = “2. Rejected” Then
        wsSource.Rows(i).Copy wsDest.Rows(destRow)
        destRow = wsDest.Cells(wsDest.Rows.Count, “I”).End(xlUp).Row + 1
        End If
        Next i

        End Sub

        • Lutfor Rahman Shimanto
          Lutfor Rahman Shimanto May 14, 2023 at 2:48 PM

          Hello CAR,

          It is great to see you again. I hope this reply finds you well. As you requested, I have reviewed your code and found some Syntax errors. But overall, the algorithm was close to achieving your goal.

          However, I am introducing a more efficient way of doing the same task with a better algorithm that should be compatible with large datasets.

          EXCEL VBA CODE:

          
          
          Sub MoveRowsInSheetsBasedOnValuesNew()
              
              Dim wsSource As Worksheet, wsDest As Worksheet
              Dim i As Long, lastRow As Long, destRow As Long
              
              Set wsSource = ThisWorkbook.Worksheets("Acquisition")
              lastRow = wsSource.Cells(wsSource.Rows.Count, "I").End(xlUp).Row
              
              
              For i = 3 To lastRow
              
                  If wsSource.Cells(i, "I").Value = "9.Projectnumber assigned" Then
                      
                      Set wsDest = ThisWorkbook.Worksheets("Projects")
                      destRow = wsDest.Cells(wsDest.Rows.Count, "I").End(xlUp).Row + 1
                      
                      wsSource.Rows(i).Copy wsDest.Rows(destRow)
                  
                  ElseIf wsSource.Cells(i, "I").Value = "10.Finished" Then
                      
                      Set wsDest = ThisWorkbook.Worksheets("Finished Projects")
                      destRow = wsDest.Cells(wsDest.Rows.Count, "I").End(xlUp).Row + 1
                      
                      wsSource.Rows(i).Copy wsDest.Rows(destRow)
                  
                  ElseIf wsSource.Cells(i, "I").Value = "1.Cancelled" Then
                      
                      Set wsDest = ThisWorkbook.Worksheets("Cancelled Rejected Proposals")
                      destRow = wsDest.Cells(wsDest.Rows.Count, "I").End(xlUp).Row + 1
                      
                      wsSource.Rows(i).Copy wsDest.Rows(destRow)
                  
                  ElseIf wsSource.Cells(i, "I").Value = "2.Rejected" Then
                      
                      Set wsDest = ThisWorkbook.Worksheets("Cancelled Rejected Proposals")
                      destRow = wsDest.Cells(wsDest.Rows.Count, "I").End(xlUp).Row + 1
                      
                      wsSource.Rows(i).Copy wsDest.Rows(destRow)
                  
                  End If
              
              Next i
              
          End Sub
          
          

          I hope this will achieve your goal. I am also giving you the Solution workbook to help you understand better.

          DOWNLOAD WORKBOOK

          Regards
          Lutfor Rahman Shimanto

        • Hi again,
          You can disregard my question about deleting a row after moving it. I have figured it out myself:

          wsSource.Rows(i).EntireRow.Delete

          I’m so happy, thanks again!

        • Avatar photo
          Shamima Sultana May 14, 2023 at 11:03 AM

          Dear Car,

          You are most welcome.

          Regards
          ExcelDemy

        • Wow, thank you so much! It works like a charm!
          I even adjusted the code for another sheet within the workbook, with different values, and it works perfectly!

          There is only one thing left, and I hope I am not bothering you too much with my questions.
          How do I get these lines to be deleted after they moved to the next sheet? I looked it up online, and found this command, but I feel it’s not complete: EntireRow.Delete

          As you may have noticed, I am new to this VBA, so I really appreciate your help!

      • Thank you for your help!

        • Lutfor Rahman Shimanto
          Lutfor Rahman Shimanto May 11, 2023 at 10:27 AM

          Thank you once again for your trust in us, CAR. Please do not hesitate to reach out if you need further assistance.

          Regards
          Team ExcelDemy

  3. How would i use the code to have different values in the cell for example differen 10 digit numbers all starting with 430

    • Reply Avatar photo
      Rubayed Razib Suprov May 7, 2023 at 11:34 AM

      Greetings Beck,
      Thanks a lot for your question. I am not entirely sure if your question is pertinent to topic of the this article, or if it is just a standalone question. I am giving you a response treating the question as a standalone question.
      To have different values in the cell which is 10 digits long and starts with 430, paste the below code in the code editor, and then press Run.

      
      Sub generate_numbers()
          Dim i As Long
          Dim myrange As Range
          Set myrange = Range("B3:B12")
          For i = 1 To myrange.Cells.Count
              myrange.Cells(i) = "430" & Format(i, "0000000000")
          Next i
      End Sub
      

      After pressing Run, you will notice that the code now put 10 distinct 10-digit values in the worksheet starting with 430.
      Hope this helps, if you have any other question or suggestions,please do not hesitate to comment on this post.

      • How would I adjust the code if I wanted to pull rows that had a value in row K of my spreadsheet and copy to sheet 2?

        • Avatar photo
          Rubayed Razib Suprov Jul 18, 2023 at 1:53 PM

          You an find the solution in the below comment of yours. I have provided a reply with a code and explanation image.

  4. What would I do differently if I had a column that had numbers in some of the rows, and those were the rows I wanted to move to sheet 2. The numbers will vary and I need it to move them if updated during the week.

    • Reply Avatar photo
      Rubayed Razib Suprov Jul 18, 2023 at 12:58 PM

      Greetings Chalon,
      Below I am going to provide a code using which you will be able to move only the rows that have value in the corresponding cells in a specific column. The sheet name here termed as “Destination” and the sheet from where we want to move the cell are named as “Source”. After putting the code in the code editor, press the Run command buton.

      
      Sub MoveRowsBasedOnValue()
          Dim sourceSheet As Worksheet
          Dim destinationSheet As Worksheet
          Dim sourceRange As Range
          Dim cell As Range
          Dim destinationRow As Long
          Set sourceSheet = ThisWorkbook.Worksheets("Move Row") ' Replace "Sheet1" with your actual sheet name
          Set destinationSheet = ThisWorkbook.Worksheets("Destination") ' Replace "Sheet2" with your actual sheet name
          Set sourceRange = sourceSheet.Range("D5:D10") ' Replace "D5:D10" with your actual range
          destinationRow = 1
          For Each cell In sourceRange
              If Not IsEmpty(cell) Then
                  sourceSheet.Rows(cell.Row).Copy Destination:=destinationSheet.Rows(destinationRow)
                  destinationRow = destinationRow + 1
              End If
          Next cell
          Application.CutCopyMode = False
          destinationSheet.UsedRange.Columns.AutoFit
          MsgBox "Rows moved successfully!"
      End Sub

      After running the code,we will see that the rows corresponding to the cell values are now mooved to the destination sheet.

  5. Sometimes I have to run this multiple times for all the rows to move, and even then I can’t get one or two to move. Any ideas?

    • Reply Avatar photo
      Rubayed Razib Suprov Jul 18, 2023 at 1:37 PM

      Greetings Valerie,
      Sorry to hear about your inconvenience. Actually from our side, we are not facing issues while moving the rows. It is working quite well. If you are incorporating this code with another code there might be an issue in the parent dataset or in the sheet name. It will be much easier for us to assist you if you can provide us with your sample code, doing so we can have a look inside the code and try to identify the issue.
      Still for your convenience, we are attaching another code, you can take a look and try y yourself. You need to change the sheets name(source and the destination) and the search value alongside the seourcerange(in which column you want to search the values).

      
      Sub MoveRowsByValue()
          Dim sourceSheet As Worksheet
          Dim destinationSheet As Worksheet
          Dim sourceRange As Range
          Dim destinationRow As Long
          Dim searchValue As Variant
          Dim lastRow As Long
          Dim cell As Range
          Set sourceSheet = ThisWorkbook.Worksheets("VBA delete original")
          Set destinationSheet = ThisWorkbook.Worksheets("Sheet1")
          Set sourceRange = sourceSheet.Range("C:C")
          searchValue = "Cable"
          lastRow = sourceSheet.Cells(sourceSheet.Rows.Count, sourceRange.Column).End(xlUp).Row
          destinationRow = 1
          For Each cell In sourceRange.Cells
              If cell.Value = searchValue Then
                  sourceSheet.Rows(cell.Row).Copy Destination:=destinationSheet.Rows(destinationRow)
                  destinationRow = destinationRow + 1
              End If
              If cell.Row = lastRow Then Exit For
          Next cell
          Application.CutCopyMode = False
          destinationSheet.UsedRange.Columns.AutoFit
          MsgBox "Rows moved successfully!"
      End Sub
  6. Hi i have an issue: it keeps saying ” run-time error “9”: subscript out of range ” and this part is highlighted

    p = Worksheets(“all books”).UsedRange.Rows.Count

    how do i fix this?

    • Hello Hermione,
      Thanks for your comment.
      The “Run-time error ‘9’: Subscript out of range” error typically occurs when VBA code tries to reference a worksheet or object that doesn’t exist in the current workbook. In your case, the error is likely occurring because there is no worksheet named “all books” in your Excel workbook.

      To fix this issue, you need to ensure that the worksheet name you’re trying to reference (“all books”) exactly matches the name of a worksheet in your workbook. If the worksheet name is different or contains typos or extra spaces, you will encounter this error.

      If you have other queries let me know in the comment.
      Regards,
      Sajid Ahmed
      Exceldemy

  7. I have a workbook that is a record of repairs by technician name (which is column D). Sheet 1 is the log with everyone which I want to keep. But I also want to move a copy of that row to the sheet of the individual technician.

    Columns in order are: Date, AE Part Number, Item OEM Serial Number, Technician, Details from Red Tag, PR# if available, Problem Identified by Repair Tech, Detailed Description of Repair Work Performed, Repair Tech Name, Repair Status, Date Repaired

    • Thanks for reaching out.

      Suppose, the technician’s name is Jim. You can follow method 1 of this article to manually copy the row after applying a filter for Jim. Then you can paste it in the sheet for Jim.

      You can also follow sub-method 2.2 of method 2 of this article to apply VBA to perform your task. In the code, you just have to change the sheet names according to your requirement. You should also modify the range to look for the technician name: in your case it’s column D.
      Suppose, the main sheet name is Sheet1 and the destination sheet name is Jim, our technician. The code will be:

      
      Sub MoveRow_KeepOriginal()
      Dim rg As Range
      Dim xc As Range
      Dim p As Long
      Dim q As Long
      Dim r As Long
      p = Worksheets("Sheet1").UsedRange.Rows.Count
      q = Worksheets("Jim").UsedRange.Rows.Count
      If q = 1 Then
      If Application.WorksheetFunction.CountA(Worksheets("Jim").UsedRange) = 0 Then q = 0
      End If
      Set rg = Worksheets("Sheet1").Range("D1:D100" & p)
      On Error Resume Next
      Application.ScreenUpdating = False
       For r = 1 To rg.Count
       If CStr(rg(r).Value) = "Jim" Then
       rg(r).EntireRow.Copy Destination:=Worksheets("Jim").Range("A" & q + 1)
       q = q + 1
      End If
      Next
      Application.ScreenUpdating = True
      End Sub
      

      This code should do the work. You can try this by changing the technician name. Hope this helped.
      Regards,
      Aung
      ExcelDemy

  8. Hi, is there any way that I can get my sheet to continue updating/moving over as I add more data to the original sheet?

    • Hi CELIA!
      To get your sheet to continue updating/moving over as you add more data to the original sheet, you must use a VBA Event. You can follow the steps to do it:
      1. Press Alt + F11 to open the VBA editor.
      2. Right-click on the Sheet1 module, choose “View Code,”
      3. Paste the code into the code window.

      
      Private Sub Worksheet_Change(ByVal Target As Range)
          Dim sourceSheet As Worksheet
          Dim targetSheet As Worksheet
          Dim intersectRange As Range
          Dim cell As Range
       
          ' Set the source and target sheets
          Set sourceSheet = ThisWorkbook.Sheets("Sheet1") ' Change to the name of your source sheet
          Set targetSheet = ThisWorkbook.Sheets("Sheet2") ' Change to the name of your target sheet
       
          ' Set the range of interest (e.g., entire columns A to Z)
          Set intersectRange = Intersect(Target, sourceSheet.Range("A:Z"))
       
          ' Check if the change occurred in the source sheet and the intersected range is not empty
          If Not intersectRange Is Nothing And Target.Parent.Name = sourceSheet.Name Then
              Application.EnableEvents = False ' Disable events to prevent infinite loop
       
              ' Clear the entire target sheet to reflect the changes
              targetSheet.Cells.Clear
       
              ' Copy the entire data from the source sheet to the target sheet
              sourceSheet.UsedRange.Copy targetSheet.Range("A1")
       
              Application.EnableEvents = True ' Enable events
       
          End If
      End Sub
      

      In this code:
      1. The Worksheet_Change event is triggered when changes occur in Sheet1.
      2. The code checks if the change occurred in Sheet1 and if the changed range intersects with the specified range (e.g., columns A to Z).
      3. If the conditions are met, it disables events to prevent infinite loops, clears Sheet2, and then copies the entire data from Sheet1 to Sheet2.
      This way, when you delete items from Sheet1, Sheet2 will be updated to reflect the changes automatically.

      Thanks for Reaching out to us.
      Regards
      Team ExcelDemy

Leave a reply

Advanced Excel Exercises with Solutions PDF

 

 

ExcelDemy
Logo