Advertisement
tpsingh26

Untitled

Jun 17th, 2021
1,188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Function Ping(strip)
  2. Dim objshell, boolcode
  3. Set objshell = CreateObject("Wscript.Shell")
  4. boolcode = objshell.Run("ping -n 1 -w 1000 " & strip, 0, True)
  5. If boolcode = 0 Then
  6.     Ping = True
  7. Else
  8.     Ping = False
  9. End If
  10. End Function
  11.  
  12. Sub PingSystem()
  13. Dim strip As String
  14. Do Until Sheet1.Range("F1").Value = "STOP"
  15. Sheet1.Range("F1").Value = "TESTING"
  16. For introw = 6 To ActiveSheet.Cells(65536, 3).End(xlUp).Row
  17.     strip = ActiveSheet.Cells(introw, 3).Value
  18.     If Ping(strip) = True Then
  19.         ActiveSheet.Cells(introw, 4).Interior.ColorIndex = 0
  20.         ActiveSheet.Cells(introw, 4).Font.Color = RGB(0, 0, 0)
  21.         ActiveSheet.Cells(introw, 4).Value = "Online"
  22.         Application.Wait (Now + TimeValue("0:00:01"))
  23.         ActiveSheet.Cells(introw, 4).Font.Color = RGB(0, 200, 0)
  24.     Else
  25.         ActiveSheet.Cells(introw, 4).Interior.ColorIndex = 0
  26.         ActiveSheet.Cells(introw, 4).Font.Color = RGB(200, 0, 0)
  27.         ActiveSheet.Cells(introw, 4).Value = "Offline"
  28.         Application.Wait (Now + TimeValue("0:00:01"))
  29.         ActiveSheet.Cells(introw, 4).Interior.ColorIndex = 6
  30.     End If
  31.     If Sheet1.Range("F1").Value = "STOP" Then
  32.         Exit For
  33.     End If
  34. Next
  35. Loop
  36. Sheet1.Range("F1").Value = "IDLE"
  37. End Sub
  38.  
  39. Sub stop_ping()
  40.     Sheet1.Range("F1").Value = "STOP"
  41. End Sub
  42.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement