I have this code in Excel 2007 however when I send it to my colleague who is using 2003, he gets
Run-time error'438":
Object doesn't support this property or method
everytime he runs the macro.
Here is the code, can you please advise what is wrong and is there anyway to fix it to have it work on 2003?
Sorry this is clumsy
Sub FilterData()
Rows("6:347").Select
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
Selection.Borders(xlEdgeLeft).LineStyle = xlNone
Selection.Borders(xlEdgeTop).LineStyle = xlNone
Selection.Borders(xlEdgeBottom).LineStyle = xlNone
Selection.Borders(xlEdgeRight).LineStyle = xlNone
Selection.Borders(xlInsideVertical).LineStyle = xlNone
Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
Range("X:AV").Select
Selection.EntireColumn.Hidden = True
Dim rng As Range, rngCriteria As Range
Set rng = Worksheets("2. Key Cities - Fixed Rates (2)").Range("A5:T280")
Set rngCriteria = Worksheets("Dashboard").Range("E2:G3")
Application.ScreenUpdating = False
' clear the paste range to receive the filtered data
Worksheets("Dashboard").Range("B6").CurrentRegion.ClearContents
' run Advanced Filter
rng.AdvancedFilter xlFilterCopy, rngCriteria, Worksheets("Dashboard").Range("B6"), False
Application.ScreenUpdating = True
Set rng = Nothing
Set rngCriteria = Nothing
Range("X:AV").Select
Selection.EntireColumn.Hidden = True
Columns("J:J").Select
Selection.Insert Shift:=xlToRight
Range("J6").Select
ActiveCell.FormulaR1C1 = "YoY Variance"
With ActiveCell.Characters(Start:=1, Length:=12).Font
.Name = "Calibri"
.FontStyle = "Bold"
.Size = 10
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ThemeColor = xlThemeColorDark1
.TintAndShade = 0
.ThemeFont = xlThemeFontNone
End With
Columns("K:K").Select
Selection.Insert Shift:=xlToRight
Range("K6").Select
ActiveCell.FormulaR1C1 = "Lead In Rate vs. Low Benchmark Rate"
With ActiveCell.Characters(Start:=1, Length:=35).Font
.Name = "Calibri"
.FontStyle = "Bold"
.Size = 10
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ThemeColor = xlThemeColorDark1
.TintAndShade = 0
.ThemeFont = xlThemeFontNone
End With
Application.ScreenUpdating = False
Sheets("Dashboard").Select
Dim LastRow As Long
LastRow = Cells.Find(What:="*", _
SearchDirection:=xlPrevious, _
SearchOrder:=xlByRows).Row
Range("J7:J" & LastRow).FormulaR1C1 = "=IF(RC[-2]="""","""",IF(ISERROR(RC[-2]-RC[-3]),""n/a"",RC[-2]-RC[-3]))"
Application.CutCopyMode = False
Application.ScreenUpdating = True
Application.ScreenUpdating = False
Sheets("Dashboard").Select
LastRow = Cells.Find(What:="*", _
SearchDirection:=xlPrevious, _
SearchOrder:=xlByRows).Row
Range("K7:K" & LastRow).FormulaR1C1 = "=IF(RC[-2]="""","""",IF(ISERROR(RC[-3]-RC[-2]),""n/a"",RC[-3]-RC[-2]))"
Application.CutCopyMode = False
Application.ScreenUpdating = True
Range("A1").Select
End Sub
Bookmarks