Wierd one here... Value question.

L

Legacy 98055

Guest
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<Unknown> 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<pre>

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</pre>
This message was edited by TsTom on 2002-05-05 23:05
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
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
 
Upvote 0
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
 
Upvote 0

Forum statistics

Threads
1,214,653
Messages
6,120,750
Members
448,989
Latest member
mariah3

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top