I am trying to set up a worksheet to automatically change formatting as the user updates a drop down or types in the selection type. My current build is functional, but I noticed that if I type in my selection and hit enter, the target function picks up the row below it.
Column 3 has a drop down box where you can select either number or %, and this tells the code to format the row as such. However if I type the identifier into row 3 and hit enter, the target function happens after the enter press, and changes row 4 with row 3's identifier.
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Value = "" Then Exit Sub
If (Target.Column <> 3) Then Exit Sub
Application.EnableEvents = False
If Target.Value = "%" Then
Application.EnableEvents = True
ActiveCell.EntireRow.Select
Selection.NumberFormat = "0.0%"
ElseIf Target.Value = "Number" Then
Application.EnableEvents = True
ActiveCell.EntireRow.Select
Selection.NumberFormat = "0"
End If
Application.EnableEvents = True
Target.Select
End Sub
I would like to figure out how to dynamically deal with the inputs if the user types the data into the field and uses enter, rather than the drop down. Any ideas?