VBA公式中的Excel工作表代号 [英] Excel Sheet Codenames in Formula VBA

查看:59
本文介绍了VBA公式中的Excel工作表代号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在VBA中创建一个公式以匹配某些行.目前我有类似的东西:

I'm trying to create a formula in VBA to match some rows. Currently I have something like:

ActiveCell.FormulaR1C1 = _
"=INDEX('Report 2'!C[4],MATCH(Report!RC[2],'Report 2'!C[8],0))"

其中报告"的工作表名称为Sheet1,而报告2"的工作表名称为Sheet2.所以我想将上面的代码更改为:

Where the sheet code name for Report is Sheet1 and sheet code name for Report 2 is Sheet2. So I would like to change the above code to something like:

ActiveCell.FormulaR1C1 = _
"=INDEX(Sheet2!C[4],MATCH(Sheet1!RC[2],Sheet2!C[8],0))"

这可能吗?它尝试搜索,但没有运气.

Is this possible? It tried searching but no luck.

谢谢!

推荐答案

...这应该做到:

ActiveCell.FormulaR1C1 = "=INDEX('" & Sheet2.Name & "'!C[4],MATCH(" & Sheet1.Name & "!RC[2],'" & Sheet2.Name & "'!C[8],0))"

这篇关于VBA公式中的Excel工作表代号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆