I haven't noticed this issue in regular Excel because I have an active filter, I can still right-click and insert a new table column. However, periodically, when I try to insert a new column in VBA, I run into a run-time 438 error when I have an active filter. Has anyone else experienced this issue? In this example, I am trying to insert a new column in the AllTable, located on the All sheet. I have pasted my code below:
The run-time error occurs on the Finding2.Insert line--from another macro, I have an active filter on the Facility_Type_Code column.
I have not posted the spreadsheet because it has so many long formulas that the character output exceeds 100,000--xl2bb won't let me post it here.
I will provide a Google Drive link in a comment.
VBA Code:
Sub CreateChemicalDetectInfo()
'Create Detects Sheet
Sheets.Add(After:=Sheets("PivotMainSheet")).Name = "Detects"
Sheets("Detects").Tab.ColorIndex = 1
'Define the AllTable
Sheets("all").Activate
Dim AllTable As ListObject
Set AllTable = Sheets("all").ListObjects("AllTable")
'Create the Detects column in the AllTable
Dim Finding2 As Range
Set Finding2 = Range("AllTable[FINDING2]")
Finding2.Insert
Range("AllTable[Column1]").Cells(0, 1).Value = "Detects"
Range("AllTable[Detects]").Cells(1, 1).Formula = "=IF([FINDING2]>0,""Detect"", ""ND"")"
'More code
End Sub
I have not posted the spreadsheet because it has so many long formulas that the character output exceeds 100,000--xl2bb won't let me post it here.
I will provide a Google Drive link in a comment.