Home |
Search |
Today's Posts |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
"Peter T" wrote:
Here's an alterntive approach [....] Function IsValidTLD(ByVal sTLD As String) As Boolean Dim sNames As String Dim arr, v sTLD = LCase$(sTLD) sNames = ".net,.com," & _ ".org,.co.uk" sNames = Replace(sNames, " ", "") arr = Split(sNames, ",") For Each v In arr If v = sTLD Then IsValidTLD = True Exit Function End If Next End Function Or more simply: Const table As String = _ ".net,.com,.org,.co.uk," ' note comma at end Function isValidDom(dom As Variant) As Long isValidDom = InStr(table, "." & dom & ",") End Function Sub testit() Dim key As Variant For Each key In Array("org", "xxx") If isValidDom(key) Then MsgBox key & " okay" _ Else MsgBox key & " bad" Next End Sub I was trying to avoid the linear comparison of 300+ names. But on second thought, an Instr solution is probably just as good. |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Set macro security level to 'low level' on opening a certain workbook. | Excel Programming | |||
Procedure level array not recognised at module level | Excel Programming | |||
The Domain www.bestnewsletter.eu is now for selling. The Domain for OVER 600 Million People in Europe. | Excel Programming | |||
The Domain www.bestnewsletter.eu is now for selling. The Domain for OVER 600 Million People in Europe. | Excel Programming | |||
Why, when I create workbook-level name does it jump it to Sheet-level ? | Excel Programming |