简体   繁体   中英

Excel Sheet Codenames in Formula 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))"

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.

Thanks!

...这应该做到:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM