delete row from the main worksheet and at the same time from the second worksheet

rodanny

New Member
Joined
Apr 24, 2024
Messages
5
Office Version
  1. 365
Platform
  1. Windows
I want to be able to automatically delete a row from sheet 2 if I delete the same row in sheet 1.
For example, in sheet 1, I delete row 25 automatically to delete row 25 in sheet 2.
I would like in vbscript and without special buttons.
Thank you
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
I believe that VBScripts cannot detect worksheet events

If you use VBA macros to detect a worksheet change, you can get the address of the deleted row and apply it to the other sheet. Is the data on both sheets identical?

Something like this. It tests if the change affects all the columns (entire row) before deleting the same row on sheet2


VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
  Dim Addr As String
  
  Addr = Target.Address
  If Target.Columns.Count = ActiveSheet.Columns.Count Then
    Addr = Target.Address
    Sheets("Sheet2").Range(Addr).EntireRow.Delete
  End If
  
End Sub
 
Upvote 1
Solution
Exactly. That's what I wanted. Thank you very much.
I still have a few problems to clear up, but I'm posting a topic with the name of the problem so that it's easy for other people to find.
 
Upvote 0

Forum statistics

Threads
1,215,444
Messages
6,124,891
Members
449,194
Latest member
JayEggleton

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top