Forum Discussion
sf49ers19238597
Sep 23, 2021Iron Contributor
I have couple formulas. I want hard code into vba
I have worksheet called PTW1 and I also have other worksheet called 1
In cell D2 have this formula
=IF('1'!D2<>"",'1'!D2,"BWT")
=IF('1'!G2<>"",'1'!G2,"BWT")
When I delete worksheet called 1 I getting #REF in D2 & G2 formulas before
I do not want #REF anymore when I delete 1. Next Year I create new 1 worksheet.
=IF(#REF!D2<>"",#REF!D2,"BWT")
=IF(#REF!G2<>"",#REF!G2,"BWT")
I want hard code vba have both formulas in code. and basic code
Thanks You
function INDIRECT()
=IF(INDIRECT("'1'!D2")<>"",INDIRECT("'1'!D2"),"BWT")=IF(INDIRECT("'1'!G2")<>"",INDIRECT("'1'!G2"),"BWT")
That I do for G2?
Thanks You
8 Replies
- mtarlerSilver ContributorInstead of hard coding in VBA you could instead use the function INDIRECT()
=IF(INDIRECT("'1'!D2")<>"",INDIRECT("'1'!D2"),"BWT")- sf49ers19238597Iron Contributor
function INDIRECT()
=IF(INDIRECT("'1'!D2")<>"",INDIRECT("'1'!D2"),"BWT")=IF(INDIRECT("'1'!G2")<>"",INDIRECT("'1'!G2"),"BWT")
That I do for G2?
Thanks You- mtarlerSilver Contributoryes that is what I'm suggesting and it appears that it is working? Glad it helped.