spmatrix
11-06-2023, 09:19 AM
Hello to all the forum.
I have the following vba code, which works fine in a sheet. How can I make it work on all the sheets or on the whole workbook, without having to pass the code to all the sheets separately?
Thanks in advance
Spiros
Private Sub Worksheet_Change(ByVal Target As Range)
Dim cell As Range
If Not Intersect(Target, Me.Range("C8:E2000")) Is Nothing Then
For Each cell In Intersect(Target, Me.Range("C8:E2000"))
If cell.Value <> "" Then
Me.Cells(cell.Row, "F").Value = Now()
Me.Cells(cell.Row, "G").Value = environ$("UserName")
Else
Me.Cells(cell.Row, "F").ClearContents
Me.Cells(cell.Row, "G").ClearContents
End If
Next cell
End If
End Sub
I have the following vba code, which works fine in a sheet. How can I make it work on all the sheets or on the whole workbook, without having to pass the code to all the sheets separately?
Thanks in advance
Spiros
Private Sub Worksheet_Change(ByVal Target As Range)
Dim cell As Range
If Not Intersect(Target, Me.Range("C8:E2000")) Is Nothing Then
For Each cell In Intersect(Target, Me.Range("C8:E2000"))
If cell.Value <> "" Then
Me.Cells(cell.Row, "F").Value = Now()
Me.Cells(cell.Row, "G").Value = environ$("UserName")
Else
Me.Cells(cell.Row, "F").ClearContents
Me.Cells(cell.Row, "G").ClearContents
End If
Next cell
End If
End Sub