SOLVED

Excel XMATCH and FILTER with PowerShell

%3CLINGO-SUB%20id%3D%22lingo-sub-2384492%22%20slang%3D%22en-US%22%3EExcel%20XMATCH%20and%20FILTER%20with%20PowerShell%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2384492%22%20slang%3D%22en-US%22%3E%3CP%3EI%20am%20trying%20to%20use%20the%20FILTER%20and%20XMATCH%20formulas%20with%20a%20PowerShell%20script%20but%20when%20I%20open%20the%20XLSX%20files%2C%20those%20formulas%20are%20not%20spilling%20over%20to%20the%20other%20rows%20and%20columns%20and%20have%20'%40'%20in%20them.%26nbsp%3B%20%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIf%20I%20manually%20remove%20the%20'%40'%20and%20press%20enter%2C%20the%20formulas%20work%2C%20spilling%20over%20and%20populating%20the%20other%20rows%20and%20columns%20as%20set.%26nbsp%3B%20%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIs%20there%20something%20extra%20I%20have%20to%20do%20within%20my%20PowerShell%20script%3F%26nbsp%3B%20I%20have%20tried%20using%20the%20.Formula%2C%20.FormulaArray%2C%20and%20.Value()%20lines.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAny%20advice%20would%20be%20much%20appreciated.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2384492%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EFormulas%20and%20Functions%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2387771%22%20slang%3D%22en-US%22%3ERe%3A%20Excel%20XMATCH%20and%20FILTER%20with%20PowerShell%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2387771%22%20slang%3D%22en-US%22%3EYou%20need%20the%20Formula2%20property%20of%20the%20Range%20object.%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2387780%22%20slang%3D%22en-US%22%3ERe%3A%20Excel%20XMATCH%20and%20FILTER%20with%20PowerShell%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2387780%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F22322%22%20target%3D%22_blank%22%3E%40Jan%20Karel%20Pieterse%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAwesome.%26nbsp%3B%20Much%20thanks.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThis%20is%20working%20for%20me%20now%20%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%24ExcelWorksheet.Cells.Item(2%2C3).Formula2%20%3D%20'%3DFILTER(...)'%3C%2FP%3E%3C%2FLINGO-BODY%3E
New Contributor

I am trying to use the FILTER and XMATCH formulas with a PowerShell script but when I open the XLSX files, those formulas are not spilling over to the other rows and columns and have '@' in them.   

 

If I manually remove the '@' and press enter, the formulas work, spilling over and populating the other rows and columns as set.   

 

Is there something extra I have to do within my PowerShell script?  I have tried using the .Formula, .FormulaArray, and .Value() lines.

 

Any advice would be much appreciated.

2 Replies
best response confirmed by JCannon2021 (New Contributor)
Solution
You need the Formula2 property of the Range object.

@Jan Karel Pieterse 

 

Awesome.  Much thanks.

 

This is working for me now :

 

$ExcelWorksheet.Cells.Item(2,3).Formula2 = '=FILTER(...)'