Please help me combine the codes below so that they work in the same worksheet.
The work if only one set is applied but not together.
Thanks
Private Sub Worksheet_Change(ByVal Target As Range)
Dim cL
If Intersect(Target, Range("I:I")) Is Nothing Then Exit Sub
For Each cL In Target.Cells
Application.EnableEvents = False
On Error GoTo enable
If Len(cL) > 40 Then
MsgBox "More than 40 characters input into cell " & Replace(cL.Address, "$", "") & vbCrLf & "Data will be Truncated", vbExclamation + vbOKOnly
cL.Value = Strings.Left(cL, 40)
Else
End If
Next cL
enable:
Application.EnableEvents = True
End Sub
Private Sub Worksheet_Change(ByVal Target As Range)
Dim FirstRow As Long
Dim i As Long
Dim LastRow As Long
Dim Rng As Range
FirstRow = 2
LastRow = Range("B:B,A:A").Find("*", , xlValues, xlWhole, xlByRows, xlPrevious, False, False, False).Row
Set Rng = Range(Cells(FirstRow, "B"), Cells(LastRow, "A"))
If Intersect(Target, Rng) Is Nothing Then Exit Sub
For i = FirstRow To LastRow
If Cells(i, "B") = "" And Cells(i, "A") <> "" Then
MsgBox "Channel ID is Missing" & vbCrLf & "Add Channel ID and Product Code together" & vbCrLf & "Data will be cleared", vbExclamation + vbOKOnly
Application.EnableEvents = False
Rng.Columns(1).Cells.ClearContents
Rng.Columns(2).Cells.ClearContents
Application.EnableEvents = True
Exit For
End If
Next i
End Sub
Bookmarks