I have some excel vba code that references worksheets by object name:
price = wks_PRICE.Range("A1")
My problem is that we have now changed all our worksheet names to camelcaps, so the worksheet object is now called "wks_Price".
But excel is still auto capitalising everything in the code back to the original capitalisation and it is then failing to run through.
ie. I will type the code:
price = wks_Price.Range("A1")
and vba will then auto change it back to
price = wks_PRICE.Range("A1")
even though "wks_PRICE" is no longer defined.
It will then crash with "Compile Error: Variable not defined"
Any ideas of how to fix? (other than changing all worksheet object names back)
wks_PRICEis a worksheet object (or possibly a variant containing a worksheet object). It is NOT the "name" of the worksheet. It is probably declared as a worksheet object at the beginning of your code. And there is no need (other than cosmetic) to change it. However, it is likely that, in changing the worksheet name, you did not properly change how this object is declared. - Ron Rosenfeld