H
hirendalal
Hi,
I have a macro which runs fine in Excel 2000 but does not run in Excel
2003. Here it is:
------------------
Sub ViewHideZeroToggle()
IsProtected = ActiveSheet.ProtectContents
If IsProtected = True Then
ActiveSheet.Unprotect
End If
If ActiveSheet.CheckBoxes("Zero Toggle").Value = xlOn Then
ZH = 12.75
Else
ZH = 0
End If
If ActiveSheet.CheckBoxes("Results Toggle").Value = xlOn Then
Res = True
Else
Res = False
End If
Application.ScreenUpdating = False
For Cell = 4 To 1000
ACell = "A" & CStr(Cell)
BCell = "B" & CStr(Cell)
If (ActiveSheet.Range(ACell).Value = "Total" And Res) Or
(ActiveSheet.Range(ACell) = "Results" And Not
ActiveSheet.Range(BCell).HasFormula And Not Res) Then
Cend = Cell
For XCell = Cend - 1 To 4 Step -1
ACell = "B" & CStr(XCell)
If ActiveSheet.Range(ACell).HasFormula Then
If ActiveSheet.Range(ACell).Value <= 0 Or
ActiveSheet.Rows(CStr(XCell) & ":" & CStr(XCell)).RowHeight = 0 Then
ActiveSheet.Rows(CStr(XCell) & ":" &
CStr(XCell)).RowHeight = ZH
End If
End If
Next XCell
End If
Next Cell
Application.ScreenUpdating = True
If IsProtected = True Then
ActiveSheet.Protect DrawingObjects:=True, Contents:=True,
Scenarios:=True
End If
End Sub
--------------------------------
The error comes at the below mentioned line:
If ActiveSheet.Range(ACell).Value <= 0 Or ActiveSheet.Rows(CStr(XCell)
& ":" & CStr(XCell)).RowHeight = 0 Then
------------------------------
The error I get is ...
Run-time error '13':
Type mismatch.
-------------------------------
I looked at similar postings on the group before but could not solve my
problem. Can somebody help in solving this problem?
Thanks.
I have a macro which runs fine in Excel 2000 but does not run in Excel
2003. Here it is:
------------------
Sub ViewHideZeroToggle()
IsProtected = ActiveSheet.ProtectContents
If IsProtected = True Then
ActiveSheet.Unprotect
End If
If ActiveSheet.CheckBoxes("Zero Toggle").Value = xlOn Then
ZH = 12.75
Else
ZH = 0
End If
If ActiveSheet.CheckBoxes("Results Toggle").Value = xlOn Then
Res = True
Else
Res = False
End If
Application.ScreenUpdating = False
For Cell = 4 To 1000
ACell = "A" & CStr(Cell)
BCell = "B" & CStr(Cell)
If (ActiveSheet.Range(ACell).Value = "Total" And Res) Or
(ActiveSheet.Range(ACell) = "Results" And Not
ActiveSheet.Range(BCell).HasFormula And Not Res) Then
Cend = Cell
For XCell = Cend - 1 To 4 Step -1
ACell = "B" & CStr(XCell)
If ActiveSheet.Range(ACell).HasFormula Then
If ActiveSheet.Range(ACell).Value <= 0 Or
ActiveSheet.Rows(CStr(XCell) & ":" & CStr(XCell)).RowHeight = 0 Then
ActiveSheet.Rows(CStr(XCell) & ":" &
CStr(XCell)).RowHeight = ZH
End If
End If
Next XCell
End If
Next Cell
Application.ScreenUpdating = True
If IsProtected = True Then
ActiveSheet.Protect DrawingObjects:=True, Contents:=True,
Scenarios:=True
End If
End Sub
--------------------------------
The error comes at the below mentioned line:
If ActiveSheet.Range(ACell).Value <= 0 Or ActiveSheet.Rows(CStr(XCell)
& ":" & CStr(XCell)).RowHeight = 0 Then
------------------------------
The error I get is ...
Run-time error '13':
Type mismatch.
-------------------------------
I looked at similar postings on the group before but could not solve my
problem. Can somebody help in solving this problem?
Thanks.