Code failing in '97 version???

roughleg

Board Regular
Joined
Jun 21, 2004
Messages
181
I created a workseet in XP and I'm having to use it on a computer at work that only has W97. Can someone tell me what i have to do to this code to make it compatible?
It's failing at the ClearContents command.

Private Sub CommandButton1_Click()
Dim NextRow As Long
With Sheets("Data")
NextRow = .Cells(Rows.Count, 1).End(xlUp).Row + 1

'Column A (1) of next row
.Cells(NextRow, 1).Value = ComboEmployees.Value

'Column B (2) of next row
.Cells(NextRow, 2).Value = DateBox.Value

'Column C (3) of next row
.Cells(NextRow, 3).Value = VacBox.Value

'Column D (4) of next row
.Cells(NextRow, 4).Value = PDBox.Value

'Column E (5) of next row
If OB1.Value = True Then
.Cells(NextRow, 5).Value = 8
Else
.Cells(NextRow, 5).ClearContents
End If

'Column F (6) of next row
.Cells(NextRow, 6).Value = AbsentBox.Value

End With

End Sub
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
It doesn't seem to have, if I'm checking correctly, but there should be a code that does the same thing shouldn't there??
Skip
 
Upvote 0
How is the code failing?

As far as I can see there's nothing in that code that isn't in both versions, including ClearContents.
 
Upvote 0
The debug dialog box comes up with that line highlighted. I assumed that was the problem.
 
Upvote 0
What actual error do you get?
 
Upvote 0
Run time error 1004
ClearContents failed at Range
Now it's seems to work most of the time. Figure that. The problem is that the user won't be able to cope.
 
Upvote 0
Run time error 1004
ClearContents failed at Range
Now it's seems to work most of the time. Figure that. The problem is that the user won't be able to cope.
 
Upvote 0
I really don't think this is an issue with the version.

It sounds more like a problem with the code.
 
Upvote 0
Do you have the sheets on your workbook prtotected. When I had to make my sheet work in 2000 i had to change around things becuase you could not be as detailed with the sheet protection. 2000 has 3 options where 2002 has many.
 
Upvote 0

Forum statistics

Threads
1,203,455
Messages
6,055,541
Members
444,794
Latest member
HSAL

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