Validate IP Address
I guess this somewhat longish non-looping one-liner will also work as
well...
Function IsValidIP(IP As String) As Boolean
IsValidIP = Not IP Like "*[!0-9.]*" And IP Like "*.*.*.*" _
And Not "." & IP & "." Like "*.[3-9]##.*" _
And Not "." & IP & "." Like "*.2[6-9]#.*" _
And Not "." & IP & "." Like "*.25[6-9].*"
End Function
--
Rick (MVP - Excel)
"Rick Rothstein" wrote in message
...
This function should do what you want...
Function IsValidIP(IP As String) As Boolean
Dim X As Long
If Not IP Like "*[!0-9.]*" And IP Like "*.*.*.*" Then
For X = 0 To 3
If Split(IP, ".")(X) 255 Then Exit Function
Next
IsValidIP = True
End If
End Function
--
Rick (MVP - Excel)
"HarryisTrying" wrote in message
...
I have a spreadsheet that contains IP addresses for computers on a
network.
I desire to look at each IP and see if it is valid using a macro.
A valid IP address is a number from 0 to 255 and has four octets
seperated
by a . (period). For example 123.234.255.231
I have tried with functions and macros and can get some results for the
first two octets but can't seem to get any farther.
If you know how to do this your help will be greatly appreciated. Using
Excel 2003 & 2007
--
Thank You
|