Type Mismatch

  • Thread starter Thread starter Steve L.
  • Start date Start date
S

Steve L.

This works on my PC but not on the mac at work.
I get a "type mismatch" error.
Mac is different?
BTW I have excel 2000 on the PC and excel 2001 on the MAC.
 
This works on my PC but not on the mac at work.
I get a "type mismatch" error.
Mac is different?
BTW I have excel 2000 on the PC and excel 2001 on the MAC.



Sub HideZeroRow()
Dim cel As Range
For Each cel In Sheets("COST VS ESTIMATE").UsedRange.Cells
If cel = 0 And cel.Column = 3 Then
cel.Select
cel.EntireRow.Hidden = True
End If
Next
End Sub
 
Just a guess (I don't own a Mac, but I've heard they're very tasty!):

Option Explicit
Sub HideZeroRow()
Dim cel As Range
For Each cel.Value In Sheets("COST VS ESTIMATE").UsedRange.Cells
If cel.Column = 3 Then
If IsNumeric(cel.Value) Then
If cel.Value = 0 Then
cel.EntireRow.Hidden = True
End If
End If
End If
Next cell
End Sub

I changed a couple of things--so if it works, you may not know what fixed it.

I added .value to cel.
and I broke the if into two different pieces.

(and I removed the .select (you didn't need that).)
 
Dave Peterson said:
Just a guess (I don't own a Mac, but I've heard they're very tasty!):

Option Explicit
Sub HideZeroRow()
Dim cel As Range
For Each cel.Value In Sheets("COST VS ESTIMATE").UsedRange.Cells
If cel.Column = 3 Then
If IsNumeric(cel.Value) Then
If cel.Value = 0 Then
cel.EntireRow.Hidden = True
End If
End If
End If
Next cell
End Sub

I changed a couple of things--so if it works, you may not know what
fixed it.

I added .value to cel.

There is a new error refering to the .value "Compile error: variable
required-can't assign to this expression".
 
Ooops. Typo.

Change this:

For each cel.value in...
to just
for each cel in ...


Sorry.

And I had another typo at the bottom! Cell instead of cel.

I tested this one (sorry again).

Option Explicit
Sub HideZeroRow()
Dim cel As Range
For Each cel In Sheets("COST VS ESTIMATE").UsedRange.Cells
If cel.Column = 3 Then
If IsNumeric(cel.Value) Then
If cel.Value = 0 Then
cel.EntireRow.Hidden = True
End If
End If
End If
Next cel
End Sub
 
Back
Top