Home » excel » Excel VBA Error'438' Object doesn't support this property or method

Excel VBA Error'438' Object doesn't support this property or method

Posted by: admin May 14, 2020 Leave a comment

Questions:

I would like to use this complicated formula in VBA, however, I keep getting the error, “Description” is one of the headers’ names from my table, would you please help me out? Thanks.

Now it shows two errors,extended the table all the way to the bottom and error 1004

Sub StartChecking()

'Spacing Check and Auto Correct

ActiveSheet.Range("O6").Formula = "=SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(TRIM(SUBSTITUTE(DVDQC_Log[@Description], ""/"", "" / "")), ""C / O"", ""C/O""), "" -"", ""-""), ""- "", ""-"")"    
Columns("O:O").EntireColumn.AutoFit
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
ActiveWindow.ScrollColumn = 6
ActiveWindow.ScrollColumn = 5
ActiveWindow.ScrollColumn = 3
ActiveWindow.ScrollColumn = 2
ActiveWindow.ScrollColumn = 1
Range("F6").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
    :=False, Transpose:=False
ActiveWindow.ScrollColumn = 2
ActiveWindow.ScrollColumn = 3
Application.CutCopyMode = False

'Pass or Fail Check

ActiveSheet.Range("P6").Formula = "=IF([DVDQC_Log[@Needed Revisions]]="", ""PASSED"", ""FAILED"")"
Columns("I:I").Select
Selection.FormatConditions.Add Type:=xlExpression, Formula1:="=$I1<>$P1"
Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
With Selection.FormatConditions(1).Interior
    .PatternColorIndex = xlAutomatic
    .ThemeColor = xlThemeColorAccent2
    .TintAndShade = 0.399945066682943
End With
Selection.FormatConditions(1).StopIfTrue = False
Range("DVDQC_Log[[#Headers],[Notes]]").Select
Selection.Copy
Range("DVDQC_Log[[#Headers],[Pass/Fail]]").Select
Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
    SkipBlanks:=False, Transpose:=False
Application.CutCopyMode = False
Application.CutCopyMode = False
ActiveWorkbook.Names.Add Name:="Address_ID", RefersToR1C1:= _
    "=DVDQC_Log[Address_ID]"
ActiveWorkbook.Names("Address_ID").Comment = ""
Columns("N:N").Select
Selection.FormatConditions.Add Type:=xlExpression, Formula1:= _
    "=LEN(TRIM(N1))=0"
Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
With Selection.FormatConditions(1).Interior
    .PatternColorIndex = xlAutomatic
    .ThemeColor = xlThemeColorAccent2
    .TintAndShade = 0.399945066682943
End With
Selection.FormatConditions(1).StopIfTrue = False
ActiveWindow.ScrollColumn = 2
ActiveWindow.ScrollColumn = 1
Range("A6").Select
End Sub
How to&Answers:

Essentially, you put a formula into a cell or range of cells; not into a worksheet. It looks like your code was adapted from a Copy & Paste operation where you can paste into the ActiveSheet’s default ActiveCell.

If O6 is one of the cells in the table with Description as one of the column names then,

Sub StartChecking()

    ActiveSheet.Range("O6").Formula = _
        "=SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(TRIM(SUBSTITUTE([@Description], ""/"", "" / "")), ""C / O"", ""C/O""), "" -"", ""-""), ""- "", ""-"")"
    ...
   Range(Range("O6"), Range("O6").End(xlDown)).Select
     ...
    ActiveSheet.Range("P6").Formula = _
        "=IF([DVDQC_Log[@Needed Revisions]]=text(,), ""PASSED"", ""FAILED"")"

End Sub

If O6 is not one of the cells in the table then you also need to include the table name in the [@Description] reference like Table1[@Description].