© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•3y ago•
1 reply
tim8w

C#.Net Excel Interop Autofilter Range

I need the following filter to work in C#.

Here is the working Macro in Excel VBA:

ActiveSheet.Range("$A$1:$XFC$13214").AutoFilter Field:=6, Criteria1:= ">=1/1/2024", Operator:=xlAnd, Criteria2:="<=1/31/2024"

Here is what I thought was the C# equivalent:

excelRange.AutoFilter(Field: 6, Criteria1: ">=1/1/2024", Operator: Microsoft.Office.Interop.Excel.XlAutoFilterOperator.xlAnd, Criteria2: "<=1/25/2024");

But I get the following runtime error in C#:

System.Runtime.InteropServices.COMException: '_AutoFilter method of Range class failed'
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

❔ C# Excel Interop - sensitivity label
C#CC# / help
3y ago
✅ Microsoft.Interop.Excel version?
C#CC# / help
3y ago
❔ Need help with C#/C++ interop
C#CC# / help
3y ago