When you click on a command button, it seem to be selected always and when a
user does not know that and they click the enter button, it runs the macro
again. How do de-select the command button once it's clicked?
Thanks
Bob Phillips - 28 Jan 2008 17:07 GMT
Disable it within the assigned macro
ActiveSheet.Buttons(Application.Caller).Enabled = False

Signature
---
HTH
Bob
(there's no email, no snail mail, but somewhere should be gmail in my addy)
> When you click on a command button, it seem to be selected always and when
> a
> user does not know that and they click the enter button, it runs the macro
> again. How do de-select the command button once it's clicked?
>
> Thanks
pgarcia - 28 Jan 2008 17:46 GMT
Oh, the command button takes you to another tab/sheet, so that did not work.
> Disable it within the assigned macro
>
[quoted text clipped - 6 lines]
> >
> > Thanks
Dave Peterson - 28 Jan 2008 17:44 GMT
Are these commandbuttons on a worksheet?
Are you using xl97?
If you are, then change the .takefocusonclick property to false. This was fixed
in xl2k.
If you ever use a control that doesn't have that property, you could also add a
line to the code:
activecell.activate
(It'll work with the commandbutton, too.)
> When you click on a command button, it seem to be selected always and when a
> user does not know that and they click the enter button, it runs the macro
> again. How do de-select the command button once it's clicked?
>
> Thanks

Signature
Dave Peterson
pgarcia - 28 Jan 2008 18:25 GMT
Great, that did the trick.
> Are these commandbuttons on a worksheet?
>
[quoted text clipped - 15 lines]
> >
> > Thanks