PDA

View Full Version : Solved: How to troubleshoot error on my macro?



genracela
04-28-2010, 01:16 AM
I have a VBA code in excel 2003-2007 compatibility mode.

It works fine with my 2007 excel, but it returned error on 2003 excel.:dunno

Is there a troubleshooting steps to avoid error on my 2003 excel?:help

my code is:


Sub calc1()
Dim lRow As Long

lRow = Range("A:A").Find(what:="*", LookIn:=xlValues, SearchOrder:=xlByRows, _
searchdirection:=xlPrevious).Row

Range("Y8:Y" & lRow).Formula = "=IFERROR((SUMIF(S8:W8,"">0"")),0)"
Range("Z8:Z" & lRow).Formula = "=IFERROR((SUMIF(S8:W8,"">0"")/SUMIF(M8:O8,"">0"")),0)"
Range("AA8:AA" & lRow).Formula = "=IFERROR((SUMIF(S8:W8,"">0"")+AK8-SUM(M8:M8)),0)"
Range("AB8:AB" & lRow).Formula = "=IFERROR(((SUMIF(S8:W8,"">0"")+AK8)/SUMIF(M8:O8,"">0"")),0)"
Range("AC8:AC" & lRow).Formula = "=IFERROR(((SUMIF(S8:W8,"">0"")+AK8)/SUMIF(M8:R8,"">0"")),0)"
Range("AD8:AD" & lRow).Formula = "=IFERROR((SUMIF(S8:W8,"">0"")-SUMIF(M8:R8,"">0"")),0)"
Range("AE8:AE" & lRow).Formula = "=IFERROR((SUMIF(S8:W8,"">0"")-SUMIF(M8:M8,"">0"")),0)"
Range("AF8:AF" & lRow).Formula = "=IFERROR((IF(VLOOKUP(A8,DH:DI,2,0)=1,1,IF(L8=0,1.4,IF(L8<=L$6,1,1.4)))),0)"
Range("AG8:AG" & lRow).Formula = "=IFERROR((IF(L8=0,IF(SUM(S8:W8)+AK8-SUM(M8:R8)>0,0,SUM(S8:W8)+AK8-SUM(M8:R8)),IF(L8<=AG$6,0,IF(SUM(S8:W8)+AK8-SUM(M8:R8)>0,0,SUM(S8:W8)+AK8-SUM(M8:R8))))),0)"
Range("AH8:AH" & lRow).Formula = "=IFERROR((ROUND(F8*AG8,0)),)"
Range("AI8:AI" & lRow).Formula = "=IFERROR((S8/(N8+O8)),0)"
Range("AJ8:AJ" & lRow).Formula = "=IFERROR((W8/(N8+O8)),0)"
Range("AK8:AK" & lRow).Formula = "=IFERROR((IF(AND($CW8<=$DB8,$DD8<100%),$CU8+CT8,0)),0)"
Range("AL8:AL" & lRow).Formula = "=IFERROR((IF(AND($CW8>$DB8,$CW8<$DC8,$DD8<100%),$CU8,0)),0)"
Range("AM8:AM" & lRow).Formula = "=IFERROR((IF(AND($CW8>$DC8+14,$CW8<$DC8+60,$DD8<100%),$CU8,0)),0)"
Range("AN8:AN" & lRow).Formula = "=IFERROR((IF(AND($CW8>=$DC8+60,$DD8<100%),$CU8,0)),0)"
Range("Y8:AP" & lRow).Copy
Range("Y8").PasteSpecial Paste:=xlPasteValues
Application.CutCopyMode = False
Range("Y8").Select

End Sub


Thanks in advance!

Bob Phillips
04-28-2010, 01:27 AM
Yes, don't use functio0nality that was introduced in Excel 2007, and is not available in Excel 2003 (IFERROR).

genracela
04-28-2010, 02:17 AM
Thanks again XLD!:)

:friends: