Range.Insert not working when filter is active

paydog23

New Member
Joined
Jul 12, 2017
Messages
28
Office Version
  1. 365
Platform
  1. Windows
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:

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
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.
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
 
Upvote 0

Forum statistics

Threads
1,215,757
Messages
6,126,695
Members
449,331
Latest member
smckenzie2016

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top