Error Checking in Excel
Thanks Thanks:  0
Likes Likes:  0
Results 1 to 4 of 4

Thread: Wierd one here... Value question.

  1. #1
    Board Regular
    Join Date
    Mar 2002
    Location
    Cincinnati, Ohio, USA
    Posts
    6,824
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    I created the following macro in Office 2000.
    The user had no problem running it on his own computer using XP. However, on another computer at his workplace, he runs 97 and said it did not work. So I tried it on 97 and the following code gives the Death Sentence: "Excel has caused an error in Excel will now close. If you continue experiencing problem try restarting you computer"

    Anyway, when I step through the following code it works fine and Excel 97 performs the same as 2000. Any one got a handle on this one?

    Thanks,
    Tom



    Private Sub Worksheet_Calculate()
    Dim NextRow As Long
    Application.EnableEvents = False
    If Range("A1") <> OldValueInA1 Then
    If Range("B1") <> 0 Then
    NextRow = Range("B1:B" & Range("B65536"). _
    End(xlUp).Row).Rows.Count + 1
    Else
    NextRow = 1
    End If
    OldValueInA1 = Range("A1")
    Range("B" & NextRow) = Format(Now, "DD-MM-YY HH:MM:SS")
    If Range("A1") = 0 Then
    If NextRow <> 1 Then
    Range("C" & NextRow) = "Stopped"
    Range("D" & NextRow) = "UP-Time"
    Range("E" & NextRow) = Format(Now - Range("B" & _
    NextRow - 1), "HH:MM:SS")
    Else
    Range("C" & NextRow) = "Stopped"
    Range("D" & NextRow) = "Insuff. Data"
    Range("E" & NextRow) = "N/A"
    End If
    Else
    If NextRow <> 1 Then
    Range("C" & NextRow) = "Started"
    Range("D" & NextRow) = "DOWN-Time"
    Range("E" & NextRow) = Format(Now - Range("B" & _
    NextRow - 1), "HH:MM:SS")
    Else
    Range("C" & NextRow) = "Started"
    Range("D" & NextRow) = "Insuff. Data"
    Range("E" & NextRow) = "N/A"
    End If
    End If
    End If
    Application.EnableEvents = True
    End Sub





    [ This Message was edited by: TsTom on 2002-05-05 23:05 ]

  2. #2
    MrExcel MVP Ivan F Moala's Avatar
    Join Date
    Feb 2002
    Location
    Auckland, New Zealand
    Posts
    4,209
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Stab in the dark...but try saving the workbook
    as an Excel97/2000 file
    Kind Regards,
    Ivan F Moala From the City of Sails

  3. #3
    Board Regular
    Join Date
    Mar 2002
    Location
    Cincinnati, Ohio, USA
    Posts
    6,824
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Thanks Ivan.
    Is there a choice for that?
    I do not have a choice for 97 and 2000.
    From the save as list I gather that 97 and 2000 are one and the same.
    Thanks,
    Tom

  4. #4
    Board Regular
    Join Date
    Mar 2002
    Location
    Cincinnati, Ohio, USA
    Posts
    6,824
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Hi.
    Found a solution, but I sure would like to know the principle behind it so I can avoid this in the future.

    When this line in the original code:

    If Range("A1") = 0 Then

    is changed to:

    If Range("A1").Value = 0 Then

    The code works fine.
    Any clues as to why?
    Thanks,
    Tom

Some videos you may like

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •