chrishooper
Technical User
Hi there,
I am trying to create Excel cell formulas that can use variables created during the execution of code in VB. In particular I would like to know if it would be possible to specify the sheet selection portion of the INDEX function based on a VB variable. For example,
If my basic INDEX function looked like this:
INDEX('Sheet Name'!D3:K6,1,1)
Could I replace the sheet name with a string variable defined in a VB subroutine like this
VB CODE:::
dim sheetname as string
sheetname = "Sheet no. 1"
EXCEL FORMULA:::
INDEX(sheetname!D3:K6,1,1) **this doesn't work yet**
I have thought about writing the string to an excel cell first in VB then picking it up with the excel formula but still without any joy. Can anyone tell me if such a procedure is possible? What syntax must i use to make it work?
Thanks in advance,
Chris.
I am trying to create Excel cell formulas that can use variables created during the execution of code in VB. In particular I would like to know if it would be possible to specify the sheet selection portion of the INDEX function based on a VB variable. For example,
If my basic INDEX function looked like this:
INDEX('Sheet Name'!D3:K6,1,1)
Could I replace the sheet name with a string variable defined in a VB subroutine like this
VB CODE:::
dim sheetname as string
sheetname = "Sheet no. 1"
EXCEL FORMULA:::
INDEX(sheetname!D3:K6,1,1) **this doesn't work yet**
I have thought about writing the string to an excel cell first in VB then picking it up with the excel formula but still without any joy. Can anyone tell me if such a procedure is possible? What syntax must i use to make it work?
Thanks in advance,
Chris.