Hi, I was working on an issue and this is the updated VBA i received from someone to use as a type of validation on a spreadsheet, but it doesnt seem to be working and i cant figure out for the life of me why it isnt.
what i originally had in mind is that when information is entered into any of the cells within cells f5:f100, there is VBA that checks to make sure the information that was entered into each cell had a character length of 8. if it was more or less, then a popup message would appear.
i cant get this to work.
any help or suggestions would be GREATLY appreciated.
thanks in advance!
-Jason
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Cells.Count < 1 Then Exit Sub
Application.EnableEvents = False
'run code depending on what column the changed cell is in
Select Case Target.Column
Case 5 'column E
'code for col E goes here
Case 6 'column F
'if changed cell is within the range F5:F100
If Not Intersect(Target, [F5:F100]) Is Nothing Then
'if cell is NOT empty and length is <>8
If Target <> "" And Len(Target) <> 8 Then
'display msg
MsgBox "There is an error in cell " & Target.Address(0, 0) & "."
End If
End If
Case 7 'column G
'code for col G goes here
End Select
Application.EnableEvents = True
End Sub
what i originally had in mind is that when information is entered into any of the cells within cells f5:f100, there is VBA that checks to make sure the information that was entered into each cell had a character length of 8. if it was more or less, then a popup message would appear.
i cant get this to work.
any help or suggestions would be GREATLY appreciated.
thanks in advance!
-Jason
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Cells.Count < 1 Then Exit Sub
Application.EnableEvents = False
'run code depending on what column the changed cell is in
Select Case Target.Column
Case 5 'column E
'code for col E goes here
Case 6 'column F
'if changed cell is within the range F5:F100
If Not Intersect(Target, [F5:F100]) Is Nothing Then
'if cell is NOT empty and length is <>8
If Target <> "" And Len(Target) <> 8 Then
'display msg
MsgBox "There is an error in cell " & Target.Address(0, 0) & "."
End If
End If
Case 7 'column G
'code for col G goes here
End Select
Application.EnableEvents = True
End Sub