Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Rob
 
Posts: n/a
Default Error on second pass of loop.

What I am trying to do is find the total amount of time my site goes down. It
all works when there is only one error in a row, but when it enters the loop
it crashes on it's second pass. Any Suggestions?

Here is how my spread sheat is laid out and what i am trying to do:
Column 'A' = Date/Time of check
Column 'D' = Check results

I want to scan down Column 'D' and find what date/time an error occured, and
if there is an error directly below that use that as the date/time. when i
have the date/time of the last CONSECUTIVE error, I then want to search going
up for the time above where it is OK. and record the difference in times.

Sub Total()

Dim ObjErrorString
Dim ObjErrorCell, ObjErrorTime
Dim ObjOkCell, ObjOkTime
Dim ObjTotal

Set ObjErrorCell = Cells.Find(What:="ERROR", After:=ActiveCell,
SearchOrder:=xlByColumns, SearchDirection:=xlNext)
ObjErrorString = "ERROR"
Do Until InStr(1, ObjErrorCell.Offset(1, 0).Value, ObjErrorString,
vbTextCompare) < 1
ObjErrorCell = ObjErrorCell.Offset(1, 0)
Loop
ObjErrorCell.Select
Set ObjErrorTime = ActiveCell.Offset(0, -ActiveCell.Column + 1)
Set ObjOkCell = Cells.Find(What:="OK", After:=ActiveCell,
SearchOrder:=xlByColumns, SearchDirection:=xlPrevious)
ObjOkCell.Select
Set ObjOkTime = ActiveCell.Offset(0, -ActiveCell.Column + 1)
ObjTotal = ObjOkTime - ObjErrorTime
Range("E389").Value = ObjTotal

End Sub
  #2   Report Post  
Dave Peterson
 
Posts: n/a
Default

You have another response at your initial thread.

Rob wrote:

What I am trying to do is find the total amount of time my site goes down. It
all works when there is only one error in a row, but when it enters the loop
it crashes on it's second pass. Any Suggestions?

Here is how my spread sheat is laid out and what i am trying to do:
Column 'A' = Date/Time of check
Column 'D' = Check results

I want to scan down Column 'D' and find what date/time an error occured, and
if there is an error directly below that use that as the date/time. when i
have the date/time of the last CONSECUTIVE error, I then want to search going
up for the time above where it is OK. and record the difference in times.

Sub Total()

Dim ObjErrorString
Dim ObjErrorCell, ObjErrorTime
Dim ObjOkCell, ObjOkTime
Dim ObjTotal

Set ObjErrorCell = Cells.Find(What:="ERROR", After:=ActiveCell,
SearchOrder:=xlByColumns, SearchDirection:=xlNext)
ObjErrorString = "ERROR"
Do Until InStr(1, ObjErrorCell.Offset(1, 0).Value, ObjErrorString,
vbTextCompare) < 1
ObjErrorCell = ObjErrorCell.Offset(1, 0)
Loop
ObjErrorCell.Select
Set ObjErrorTime = ActiveCell.Offset(0, -ActiveCell.Column + 1)
Set ObjOkCell = Cells.Find(What:="OK", After:=ActiveCell,
SearchOrder:=xlByColumns, SearchDirection:=xlPrevious)
ObjOkCell.Select
Set ObjOkTime = ActiveCell.Offset(0, -ActiveCell.Column + 1)
ObjTotal = ObjOkTime - ObjErrorTime
Range("E389").Value = ObjTotal

End Sub


--

Dave Peterson
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
error on second pass of loop. Rob Excel Discussion (Misc queries) 3 September 9th 05 07:01 PM
Do Loop BobBarker Excel Worksheet Functions 0 August 19th 05 08:44 PM
Do Loop BobBarker Excel Worksheet Functions 0 August 19th 05 07:45 PM
VB for excel, how do I loop through code steve hobden via OfficeKB.com Excel Discussion (Misc queries) 2 June 9th 05 01:59 PM
loop trough e-mail address list to send task lists with outlook Paul. Excel Discussion (Misc queries) 2 April 14th 05 11:48 AM


All times are GMT +1. The time now is 10:43 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"