good morning I need to combine two Private Sub Worksheet_Change(ByVal Target As Range) I'm new to Excel VBA code, how can I do this? Code below.
1)
Option Explicit
Const strAFM As String = "D3:D1000"
Private Sub Worksheet_Change(ByVal Target As Range)
Dim Rng As Range, AFM As String, rngTomi As Range
Set Rng = Range(strAFM)
Set rngTomi = Intersect(Target, Rng)
If rngTomi Is Nothing Then Exit Sub
If rngTomi.Count <> 1 Then
rngTomi.ClearContents
Exit Sub
End If
If Trim(Target.Value) = "" Then Exit Sub
AFM = Right("000000000" & Target.Value, 9)
If isAFM(AFM) = False Then
MsgBox "no afm"
Target.Activate
Exit Sub
End If
End Sub
2)
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Count > 1 Then Exit Sub
Dim Rng As Range
Set Rng = Me.Range("ColTarget")
If Intersect(Target, Rng) Is Nothing Then Exit Sub
ResizeTbl
End Sub