Macro using Command Button Vs. Ctrl Key


Posted by Marianne on January 11, 2001 10:35 AM

Hello,

I originally wrote a macro and had it work when Ctrl m was typed. Now, I recently discovered that I can insert Command Buttons in my worksheet. I thought that I would be able to use the same macro for the Command Button but it does not work. I am very new at this, so bear with me. Here is an example of where it gets hung up.

'Note: I am in worksheet 1.
Sheets("Worksheet 2").Select
Rows("10:10").Select

The code goes on, but I can't get past the Rows command with the Command Button and it works fine with Ctrl m.

Is there an explanation for this? Like for instance, is macro coding different when you are using VB command buttons?

Thanks,

Marianne

Posted by Dave Hawley on January 12, 2001 1:52 AM


Hi Marianne

Sounds like your using a Button from the Control Toolbox (ActiveX). Right click on the Button and select "Propeties" , scroll down to "TakeFocusOnClick" and set this to False.

...Or put: [A1].Select
as the first line in your code, this will set focus back to your Sheets.


....Or use a button from the Forms toolbar.

Hope this helps, if no could you paste the rest of the code here ?

Dave
OzGrid Business Applications



Posted by Marianne on January 12, 2001 4:06 PM

Thank you! Button from Forms Tool Bar is the Solution! (NTF)