ArmadaShari
New Member
- Joined
- Jun 23, 2017
- Messages
- 4
Good morning - I'm a relative novice with coding for Excel. I know just enough to be dangerous, so please bear with me.
I'm using the following code to enable dates to be entered into certain columns using just 6 digits and it will automatically format it as a date with the slash characters.
How can I amend this so that it does NOT apply to the 1st (header) row?
Thank you,
Shari
I'm using the following code to enable dates to be entered into certain columns using just 6 digits and it will automatically format it as a date with the slash characters.
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Select Case Target.Column
Case 4, 7, 8, 20, 21, 28, 30, 33, 34 ' columns numbers of dates
TypedVal = Application.WorksheetFunction. _
Text(Target.Value, "000000")
NewValue = Left(TypedVal, 2) & "/" & _
Mid(TypedVal, 3, 2) & "/" & _
Right(TypedVal, 2)
Case 22 ' Column U is a time column
TypedVal = Application.WorksheetFunction. _
Text(Target.Value, "0000")
NewValue = Left(TypedVal, 2) & ":" & _
Right(TypedVal, 2)
End Select
If NewValue > 0 Then
Application.EnableEvents = False
Target.Value = NewValue
Application.EnableEvents = True
End If
End Sub
How can I amend this so that it does NOT apply to the 1st (header) row?
Thank you,
Shari