Need assistance using a variable in R1C1 formula to set row number. Goal is to use variable "lngAccount_ER" to replace hard code "120" in formula end-rows
lngAccount_ER = xxx
.Cells(1, 34).FormulaArray = "=INDEX(R12C29:R120C29,MATCH(RC31&R10C&R9C,R12C22:R120C22&R12C28:R120C28&R12C27:R120C27,0))"
I attempted the below, but im sure my syntax is off:
.Cells(1, 34).FormulaArray = "=INDEX(R12C29:R & lngAccount_ER & C29,MATCH(RC31&R10C&R9C,R12C22:R& lngAccount_ER & C22&R12C28:R& lngAccount_ER & C28&R12C27:R & lngAccount_ER & C27,0))"
Thanks for your help!!
Everytime you are mixing a "hard-coded" String
with a variable, you need to close the string with "
and add the &
. The same goes after the variable, add the &
and also the "
before the next string.
You were close, modify your line:
.Cells(1, 34).FormulaArray = "=INDEX(R12C29:R & lngAccount_ER & C29,MATCH(RC31&R10C&R9C,R12C22:R& lngAccount_ER & C22&R12C28:R& lngAccount_ER & C28&R12C27:R & lngAccount_ER & C27,0))"
To:
.Cells(1, 34).FormulaArray = "=INDEX(R12C29:R" & lngAccount_ER & "C29,MATCH(RC31&R10C&R9C,R12C22:R" & lngAccount_ER & "C22&R12C28:R" & lngAccount_ER & "C28&R12C27:R" & lngAccount_ER & "C27,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.