View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
JLatham JLatham is offline
external usenet poster
 
Posts: 2,203
Default Validation of Employee Timesheet

Well, I don't know about eliminating all possible error entries since humans
seem to have an almost infinite capacity for screwing up a typed entry, but...
This code will test entries and replace commas and colons with a period
which should help most of the time.

To put the code to work, open your workbook, go to the time entering sheet
and right-click on its name tab and choose [View Code] from the list that
appears. Copy the code below and paste it into the code module presented to
you. Make any change needed to get it to work in the correct column(s).
Close the VB Editor and give it a try.

Private Sub Worksheet_Change(ByVal Target As Range)
'check for changes in a column and if the entry
'in the cell changed, replace commas or colons with periods.
'
'can be modified to check any number of columns
'
Dim newEntry As String
Application.EnableEvents = False ' prevent re-entry
newEntry = Target.Text
Select Case Target.Column
Case Is = 3 ' column C
newEntry = Replace(newEntry, ",", ".")
newEntry = Replace(newEntry, ":", ".")
Case Else
'do nothing
End Select
Target.NumberFormat = "General"
Target.Value = newEntry
Application.EnableEvents = True ' for next time
'
'if you wish to check multiple columns, then
'just change the initial Case Is = statement to
'include all column numbers, as this example
'for columns C, G and R
' Case Is = 3, 7, 18

End Sub

"RoRo123" wrote:

Errors with Hrs. entry by employees. Occasional keying errors such as colons
(8:00), commas (8,00), etc. How do I set up a validation that eliminates all
possible error entries other than regular hr. entries with 2 decimal places,
and gives a pop-up error message? We are using Excel 2003.
--
RGS