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

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
 
Upvote 0

Forum statistics

Threads
1,224,869
Messages
6,181,484
Members
453,046
Latest member
Excelvbaexpert

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