Can't change NumberFormat via Command button
I have a piece of code as follows :
Dim myCell as Range
For Each myCell in Selection
MyCell.NumberFormat = "@"
Next myCell
When I select a range of cells manually and run the macro from the <Tools
menu in Excel '97, it works fine but the problem is that if I put this code
in a button_click Sub, I get the error message 'Unable to change the
NumberFormat property of the Range Object' for the code 'myCell.NumberFormat
= "@".
Could someone suggest a reason(s) as to why this happens, I am completely
dumbfounded.
|