How do I store the address of a deleted cell during Worksheet_Change Event?

Drawleeh

New Member
Joined
Sep 2, 2021
Messages
34
Office Version
  1. 2016
  2. 2010
Platform
  1. Windows
I know that the worksheet_change event is fired when a cell is deleted. Can I store the address of that cell that was just deleted to use it to then delete the same cell reference in other sheets? For example if I delete A3 on Sheet1, can I then select A3 on Sheet 2 and Sheet 3 and delete it on those ones too in the same worksheet change event?
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
Try this code, which will remove the value from all other sheets when removed from the sheet with this procedure attached to it:
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)

    Dim cell As Range
    Dim addr As String
    Dim ws As Worksheet
    Dim shName As String
    
'   Loop through cells just updated
    For Each cell In Target
'       Check to see if value was deleted (so no value left)
        If cell.Value = "" Then
'           Capture cell address and active sheet name
            addr = cell.Address
            shName = ActiveSheet.Name
'           Loop through other sheets
            For Each ws In Worksheets
                If ws.Name <> shName Then
'                   Clear cells on other sheets
                    ws.Range(addr).ClearContents
                End If
            Next ws
        End If
    Next cell

End Sub
 
Upvote 0

Forum statistics

Threads
1,223,888
Messages
6,175,212
Members
452,618
Latest member
Tam84

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