通过 VBA 插入数组公式 [英] Insert an Array Formula via VBA
本文介绍了通过 VBA 插入数组公式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用 VBA,我需要插入一个数组公式(如果我手动编写它,我将按 Ctrl+Shift+Enter 而不仅仅是 Enter).当我像常规公式一样插入它时,它不起作用,当我将它与 {} 放在一起时...使用 VBA 编写该公式的正确方法是什么?
I'm using VBA, and I need to insert an array formula (the one that if I'm writing it manually, I'll press Ctrl+Shift+Enter and not just Enter). When I'm inserting it like a regular formula it doesn't work, neither when I put it with {} around it... What's the correct way of writing that formula using VBA?
公式是这样的:
=INDEX(subset!R1C1:R2472C10,MATCH(1,(RC1=subset!C1)*(RC2=subset!C2)*(RC5=subset!C5)*(RC6=subset!C6),0),10)
推荐答案
您正在寻找可以为单元格设置的 FormulaArray
属性,如下所示:
You're looking for the FormulaArray
property that you can set for a cell like so:
Range("A1").FormulaArray = "=INDEX(subset!R1C1:R2472C10,MATCH(1,(RC1=subset!C1)(RC2=subset!C2)(RC5=subset!C5)*(RC6=subset!C6),0),10)"
请参阅此处的文档:http://msdn.microsoft.com/en-us/library/office/ff837104%28v=office.15%29.aspx
这篇关于通过 VBA 插入数组公式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文