Lookup value with coding said:
I want to ping a IP list in excel and add the ping status to the column on
the right next to the ip adres?
If you are using Windows XP, there is a WMI Win32_PingStatus class (you need
administrator privileges to run this):
Function Ping1(Host As String) As Boolean
Ping1 = False
Set objPing = GetObject _
("WinMgmts:{impersonationLevel=impersonate}"). _
ExecQuery("Select * From Win32_PingStatus " & _
"Where Address = '" & Host & "'")
For Each objStatus In objPing
If IsNull(objStatus.StatusCode) _
Or objStatus.StatusCode <> 0 Then
Ping1 = False
Else
Ping1 = True
End If
Next
Set objPing = Nothing
End Function
Also, you can use WshShell.Exec function to run Ping command and check the
output:
Function Ping2(Host As String) As Boolean
Ping2 = False
Status = CreateObject("WScript.Shell"). _
Exec("Ping " & Host).StdOut.ReadAll
If InStr(Status, "Received = 0") = 0 Then
Ping2 = True
Else
Ping2 = False
End If
End Function
You can modify this to accept optional Ping arguments (like -n or -w etc).
Hope this helps.