Вы находитесь на странице: 1из 2

Excel 2010

VB for Apps 7.0

Dear all,

Im hoping someone could help me!

Stage 1

I have a Excel spreadsheat named - CommsMASTER.xlsm thats runs the following macro;

Sub ping08()

For Each tmpCell In Range("D2:D1027").SpecialCells(2, 2)

If InStr(CreateObject("WScript.Shell").Exec("%comspec% /c Ping -4 -n 1 -w 750 " &


tmpCell).StdOut.ReadAll, "TTL=") Then
tmpCell.Offset(0, 3) = "OK"

Else

tmpCell.Offset(0, 3) = "Failed"

End If

Next

End Sub

This VB script basically pings a number of IP address (1027 rows) and records the results as follows in
Excel;

The times will run from 08:00 to 07:00.

C D E F G H I J K
1 Site No. Internal IP External IP Site Name 08:00 09:00 10:00 11:00 12:00
2 0.91909 10.131.307.100 105.26.89.161 DERTRED OK
3 0.91909 10.121.507.100 105.26.89.161 RETRO Failed

I would like to automate the process so the script runs automatically every hour and then records the
results in each consequent/relevant cell. So next result at 9:00 in H2 and 10:00 in I2 etc etc.

I have been looking at the Application.OnTime TimeValue("10:57:00"), "ping08" function but just
cant anything to work as I would like.

I would also have another failure rate column on the end.


As shown above, I have over 1000 rows to go through. I will have a dedicated server that this could
run on.

Stage 2.

If Stage 1 works correctly, then we should see something like this;

C D E F G H I J K L
1 Failure
Site No. Internal IP External IP Site Name 08:00 09:00 10:00 11:00 12:00 Rate
2 0.91909 10.131.307.100 105.26.89.161 DERTRED OK OK OK OK OK 0%
4 0.91909 10.121.507.100 105.26.89.161 RETRO Failed OK Failed Failed Failed 80%
5 0.91909 10.131.307.100 105.26.89.161 DERTRED OK OK OK Failed Failed 40%

The failure rate column will work out the percentage rate at which we record a ‘Failed’.

I would then like anything that has a failure rate of greater or equal to 50% to output to the second
tab (Comms FAILURE).

Stage 3.

Spreadsheet saved with current date with format ‘Comms Report 06_02_13’ and then emailed to
everyone that is listed in .lst text file.

Everything above needs to be automated. So could use scheduled tasks etc.

So overall we need to;

1. Open Excel spreadsheet


2. Run Macro to ping every hour
3. Records results
4. Outputs results to second tab
5. Saves spreadsheet every hour with format above
6. Emails spreadsheet after macro run at 08:00

Вам также может понравиться