I have code to paste a value into all worksheets in a workbook (it does work but its a little slow).
Then it should when a value is deleted, delete that row from every other worksheet, but it does nothing.
Debugging it looks like the Application.CountBlank(irg) = 1
is never met even though IRG
upon cell deletion as the target cell should definitely be blank and a delete should run the worksheet change event.
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
Const cCol As String = "A"
Const fRow As Long = 2
Dim crg As Range
Dim ddFound As Range
Dim ws As Worksheet
Dim sh As Worksheet
Dim outpt As String
Dim i As Integer
Application.EnableEvents = False
Set crg = Columns(cCol).Resize(Rows.Count - fRow + 1).Offset(fRow - 1)
Dim irg As Range: Set irg = Intersect(crg, Target)
Dim sraddress As String
Dim dws As Worksheet
Dim ddcrg As Range
For Each ws In ActiveWorkbook.Worksheets
Set ddcrg = ws.Columns(cCol)
sraddress = irg.Value2
Set ddFound = ddcrg.Find(sraddress, , xlValues, xlWhole)
Application.ScreenUpdating = False
If Application.CountBlank(irg) = 0 Then
If ddFound Is Nothing Then
irg.Select: ActiveCell = irg.Value2
irg.Copy
ws.Range(irg.Address) = irg.Value2
Application.CutCopyMode = False
ElseIf Application.CountBlank(irg) = 1 And ddFound Is Nothing Then
Sheets(Array("Statistics", "January")).Select
ddFound.EntireRow.Delete Shift:=xlShiftUp
End If
End If
Next ws
Application.ScreenUpdating = True
Application.EnableEvents = True
End Sub