Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.misc
|
|||
|
|||
Excel 2000 macro not working in Excel 2003
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. |
#2
Posted to microsoft.public.excel.misc
|
|||
|
|||
Excel 2000 macro not working in Excel 2003
Check out this website http://support.microsoft.com/default...b;en-us;821292 Should help you. I pasted it into my excel 2003 and it worked fine maybe are you copying and pasting beacuse i have heard that impoting from a different version of excel can sometime skew things to make them not work. -- Zygan ------------------------------------------------------------------------ Zygan's Profile: http://www.excelforum.com/member.php...o&userid=34423 View this thread: http://www.excelforum.com/showthread...hreadid=548520 |
#3
Posted to microsoft.public.excel.misc
|
|||
|
|||
Excel 2000 macro not working in Excel 2003
Hi Zygan,
Thanks for your reply. Actually, the macro was written in Excel 2000 and now i am running it on Excel 2003. I checked the site and it suggest that I upgrade to SP2 which is already there. I still get the same error. I tried it on Excel 2000 on another computer and it worked fine. Hence, I am not sure if something is wrong with my install of Excel 2003 OR something is wrong with the Macro itself. What do you suggest? Thanks. -Hiren. Zygan wrote: Check out this website http://support.microsoft.com/default...b;en-us;821292 Should help you. I pasted it into my excel 2003 and it worked fine maybe are you copying and pasting beacuse i have heard that impoting from a different version of excel can sometime skew things to make them not work. -- Zygan ------------------------------------------------------------------------ Zygan's Profile: http://www.excelforum.com/member.php...o&userid=34423 View this thread: http://www.excelforum.com/showthread...hreadid=548520 |
#4
Posted to microsoft.public.excel.misc
|
|||
|
|||
Excel 2000 macro not working in Excel 2003
I am not really sure on the workings around installing / resinstalling to make an effect on the program but looking at the code try and break it down so that you can sort out which part is the real error e.g you have and if and or command try If ActiveSheet.Range(ACell).Value <= 0 then if ActiveSheet.Rows(CStr(XCell)& ":" & CStr(XCell)).RowHeight = 0 Then ActiveSheet.Rows(CStr(XCell) & ":" & CStr(XCell)).RowHeight = ZH END IF END IF give this a go and let me know. -- Zygan ------------------------------------------------------------------------ Zygan's Profile: http://www.excelforum.com/member.php...o&userid=34423 View this thread: http://www.excelforum.com/showthread...hreadid=548520 |
#5
Posted to microsoft.public.excel.misc
|
|||
|
|||
Excel 2000 macro not working in Excel 2003
Hi Zygan,
Now the same error comes at the following line: If ActiveSheet.Rows(CStr(XCell) & ":" & CStr(XCell)).RowHeight = 0 Then Can you help me figure what's wrong with the above line when we know that it works with Excel 2000. Thanks, -Hiren. Zygan wrote: I am not really sure on the workings around installing / resinstalling to make an effect on the program but looking at the code try and break it down so that you can sort out which part is the real error e.g you have and if and or command try If ActiveSheet.Range(ACell).Value <= 0 then if ActiveSheet.Rows(CStr(XCell)& ":" & CStr(XCell)).RowHeight = 0 Then ActiveSheet.Rows(CStr(XCell) & ":" & CStr(XCell)).RowHeight = ZH END IF END IF give this a go and let me know. -- Zygan ------------------------------------------------------------------------ Zygan's Profile: http://www.excelforum.com/member.php...o&userid=34423 View this thread: http://www.excelforum.com/showthread...hreadid=548520 |
#6
Posted to microsoft.public.excel.misc
|
|||
|
|||
Excel 2000 macro not working in Excel 2003
the line looks like ther is nothing wrong with it do you mind if you try this code what happens If ActiveSheet.Range(ACell).Value <= 0 Then ActiveSheet.Rows(CStr(XCell) & ":" & CStr(XCell)).RowHeight = ZH end if does it make the row height 12.5/0 if it does then this it cannot define/find out wether or not this is true ActiveSheet.Rows(CStr(XCell) & ":" & CStr(XCell)).RowHeight = 0 try this ActiveSheet.Rows("" +CStr(XCell) + "":"" + CStr(XCell)+ "").RowHeight = 0 or this (cannot remember which one it is lol) ActiveSheet.Rows(" +CStr(XCell) + "":"" + CStr(XCell)+ ").RowHeight = 0 if the code up above does not work then it cannot define CSTr and Xcell i noticed your code never actually gives them a "starting value" try giving them a value CSTr = ... XCell = ... or defining them e.g CSTr as .... abd XCell as ... at the start of your macro hope this finally sorts it out -- Zygan ------------------------------------------------------------------------ Zygan's Profile: http://www.excelforum.com/member.php...o&userid=34423 View this thread: http://www.excelforum.com/showthread...hreadid=548520 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
macro from excel 97 that doesnt work in excel 2003 (help) | Excel Discussion (Misc queries) | |||
GetSaveAsFilename not working in Excel 2003 | Excel Discussion (Misc queries) | |||
Excel 2000 to 2003 update links doesn't work properly any suggest | Excel Worksheet Functions | |||
Excel Re-calculation 2000 compared to 2003 | Excel Discussion (Misc queries) | |||
Excel 2000 to Excel 2003.... is it worh it? | Excel Discussion (Misc queries) |