Thread: Range.Select
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Mike[_73_] Mike[_73_] is offline
external usenet poster
 
Posts: 8
Default Range.Select

"scottnshelly " wrote in
message ...
I have a very uncomplicated code that is giving me troubles. i have
been trying to figure this out for much longer than i want to admit.
here is the code.

Private Sub CommandButton2_Click()


it is giving me the following error: Run-time error '1004': Select
method of range class failed
when i go to debug it highlights line 14 - range("ah7").select.
i have tried moving this line, and changing it. any suggestions?




It sounds like the button that your code is attached to still has
focus. Try changing the TakeFocusOnClick property of the button to
False. This should prevent the error from occurring.

FWIW, it looks like there are several lines of code that could be
removed safely. Most of the stuff that we need to do with code can be
done without changing the selection and referring to
ActiveSheet/ActiveCell. Doing so will improve performance and make
the code easier to maintain.


Hope this helps,

-Mike