View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.misc
Dave Peterson Dave Peterson is offline
external usenet poster
 
Posts: 35,218
Default Alt+F11, writing macros and assigning to a button

With a macro name like Commandbutton1_Click, this means that the commandbutton
was added from the Control toolbox toolbar.

There is another button on the Forms toolbar that looks the same (kind of), but
behaves differently.

When you use the commandbutton from the control toolbox toolbar, you don't
assign a macro. You can just doubleclick on that commandbutton and be taken to
the worksheet module (not a general module) where the code would be locacted.

When you use the button from the Forms toolbar, then you can assign a macro to
this button that exists in a General module.

There are lots of places to learn about excel macros:
Debra Dalgleish has some notes how to implement macros he
http://www.contextures.com/xlvba01.html

David McRitchie has an intro to macros:
http://www.mvps.org/dmcritchie/excel/getstarted.htm

Ron de Bruin's intro to macros:
http://www.rondebruin.nl/code.htm

(General, Regular and Standard modules all describe the same thing.)

And if you like reference books...

Debra Dalgleish has a list of books at her site:
http://www.contextures.com/xlbooks.html

John Walkenbach's books are very good to start.

Professional Excel Development by Stephen Bullen, Rob Bovey, John Green is
pretty advanced, but very good.

See if you can find them in your local bookstore/internet site and you can
choose what one(s) you like best.

CousinExcel wrote:

Hi,

Recently KevHardy asked a question with a very nice text and
Master Mike H. (who can also inititate chemical reactions in Excel when
needed I believe) has given the solution, effective, easily understandable as
always.
(It was on Feb 11 or 12).

The answer was a macro like:
"Private Sub CommandButton1_Click()
If Selection.Rows.Count 1...

In that answer
- Alt+F11: I learned it. Then should I say insert MODULE or different ?
- Then, I inserted the 'command button' on the worksheet, okay. Right click
the 'command button, select 'Assign Macro' then I could not see the macro I
wrote ? (I could run it by copying, pasting etc., a long way).

Additional question, can I find the list of commands like
"Selection.Rows.Count" etc. somewhere in the internet.

Thanks and regards,

Cousin Excel


--

Dave Peterson