excel - When writing string to a cell, VBA inserts extra single quotation marks -


i trying write formula using vba:

activecell.value = "=f(r[-1]c[0],sheet1!" & columnletter & & ")" 

where columnletter variable letter macro computes earlier, , f function, , number.

the problem when run this, cell given instead: (if columnletter = f, = 16):

=f(r[-1]c[0],sheet1!'f16') 

but want:

=f(r[-1]c[0],sheet1!f16) 

why vba or excel putting single quotation marks around f16? not insert these quotation marks if not include r[-1][0] argument in formula, need include this.

help appreciated!

its combination of r1c1 , a1 addressing. need pick 1 method , use both parts.
note if type =f(r[-1]c[0],sheet1!f16) cell error same reason.

you need use r1c1 style first address, (assuming because don't want absolute address) can use .offset instead

activecell.value = "=f(" & replace(activecell.offset(-1, 0).address, "$", "") _  & ",sheet1!" & columnletter & & ")" 

Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -