View Single Post
  #10   Report Post  
Posted to microsoft.public.excel.programming,microsoft.public.excel.worksheet.functions
Dana DeLouis[_3_] Dana DeLouis[_3_] is offline
external usenet poster
 
Posts: 690
Default A better way to create this function. To long for Data Validation.

Nice! Another similar way might be with "Like."

MsgBox "30:01:00" Like "[0-9][0-9]:[0-5][0-9]:[0-5][0-9]"
MsgBox "30:61:00" Like "[0-9][0-9]:[0-5][0-9]:[0-5][0-9]"

--
Dana DeLouis
Using Windows XP & Office XP
= = = = = = = = = = = = = = = = =


"onedaywhen" wrote in message
om...
Because you cross-posted to microsoft.public.excel.programming, here's
an approach that uses regular expressions:

Private Sub Test()
Dim m_oVbs As Object
Set m_oVbs = CreateObject("VBScript.RegExp")
With m_oVbs
.Pattern = "[0-9][0-9]:[0-5][0-9]:[0-5][0-9]"
MsgBox .Test("30:01:00")
End With
End Sub

--

"arno" wrote in message

...
Hi Niklas,

In a text cell I want to check if the user have entered a valid

interval.
A valid intervall looks like this 33:01:00.

why don't you use a cell that is formatted as time, [hh]:mm:ss? then you
only have to validate data (menu Data) to be less than the "time"

100:00:00.

regards

arno