Hello, I'm looking for two Private Sub Worksheet_Change for one sheet.
I need these to both to work, but can only get the first one to work.
Is there a way to get these to work by combining them somehow?
Private Sub Worksheet_Change(ByVal Target As Range)
' Auto Date
Dim Cell As Range
For Each Cell In Target
If Cell.Column = Range("I:I").Column Then
If Cell.Value <> "" Then
Cells(Cell.Row, "D").Value = Now
Else
Cells(Cell.Row, "D").Value = ""
End If
End If
Next Cell
End Sub
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
Dim rng As Range
If Target.Address <> "$A$1" Then Exit Sub
Set rng = Cells.Find(What:=Target.Value, After:=Target, LookIn:=xlValues, LookAt:=xlWhole)
If rng.Address = Target.Address Then
MsgBox "Not found!", vbOKOnly, "Search for '" & Target.Value & "'"
Exit Sub
End If
rng.Activate
End Sub
I need these to both to work, but can only get the first one to work.
Is there a way to get these to work by combining them somehow?
Private Sub Worksheet_Change(ByVal Target As Range)
' Auto Date
Dim Cell As Range
For Each Cell In Target
If Cell.Column = Range("I:I").Column Then
If Cell.Value <> "" Then
Cells(Cell.Row, "D").Value = Now
Else
Cells(Cell.Row, "D").Value = ""
End If
End If
Next Cell
End Sub
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
Dim rng As Range
If Target.Address <> "$A$1" Then Exit Sub
Set rng = Cells.Find(What:=Target.Value, After:=Target, LookIn:=xlValues, LookAt:=xlWhole)
If rng.Address = Target.Address Then
MsgBox "Not found!", vbOKOnly, "Search for '" & Target.Value & "'"
Exit Sub
End If
rng.Activate
End Sub