Thank you for being a valued part of the CNET community. As of December 1, 2020, the forums are in read-only format. In early 2021, CNET Forums will no longer be available. We are grateful for the participation and advice you have provided to one another over the years.

Thanks,

CNET Support

General discussion

How do you create a macro button

Apr 13, 2007 4:44AM PDT

I had gotten this response from an earilier question I had asked. I built the two worksheets, but I am not sure how to create a macro button that will take me to the right sheet.

"easiest way would be to replace using a drop down with 2 macro buttons - option a , and option b. Set up 2 separate forms on different worksheets, form a and form b.record a macro for each button to takes you to the right form and hides the other one.you can also get the macros to populate specific cells depending on which button is pressed."

Thanks in advance for the help

Discussion is locked

- Collapse -
Re: how to create a button with a macro in Excel
Apr 13, 2007 5:31AM PDT

Just by accident, I did exactly this half an hour ago, by way of troubleshooting an old application I had written.
The last time was at least a year before. I must admit I had to use the help to point me the way again. Did you use the help? If not, why not?

Broadly speaking, it goes like this:
1. Create the macro.
2. Open the forms toolbar.
3. Drag the button from that toolbar to the form, and change the appearance (text, size) to your wishes.
4. Right click and assign the macro from #1 to this button.

The methods to use on the sheet-object in the macro are select and activate. The difference isn't really clear to me (I'm a beginner in Excel VBA) but the combination works quite satisfactory.

Hope this helps.


Kees

- Collapse -
How to create and assign a Forms button
Apr 13, 2007 5:34AM PDT

This is easy to do in Excel.

If you do not have the Forms toolbar visible, goto View > Toolbars, and select Forms. You will see the Forms toolbar appear.

In this toolbar is a small grey button. Click on it, and then on your worksheet click and drag a border to the desired size. As soon as you let go the mouse button the Assign Macro window will appear and you can assign the macro you want the button to use.

If you haven't done the macro yet, just cancel that. You can always right click the button and select "Assign Macro" later. You can also right click and select "Edit text" to change the name on the button.

I hope that helps.

Mark

- Collapse -
macros in word
Apr 13, 2007 5:50AM PDT

Is there any way to put a button that opens another sheet in word?

- Collapse -
Please explain.
Apr 13, 2007 8:20AM PDT

Worksheets are something in an Excel workbook (a .xls file). Word has documents (.doc files) - and Powerpoint has presentations (.ppt files).
So "sheets" in Word is undefined.

And where would you want to put the button? In the toolbar, or in a document? Some background would be nice also. It's a rather uncommon request.

Kees

- Collapse -
clarification
Apr 15, 2007 11:22PM PDT

I am trying to recreate a form that was designed in adobe acrobat. The first box on the form has 2 choices. The top of the form stays the same (ie name, address) When you pick the first choice, a set of 8 check boxes appear on the second half of the form. When you pick choice 2, a set of 6 check boxes appear. The problem is unless you have adobe professional, you can not save the form, so the people who use if have to continually put the same info in over and over.

I am trying to duplicate the functionality of this form in word. Someone on the board suggested that I make 2 seperate sheets (Form A and Form B). He then suggested using a macro so that when you chose one, it opens the appropriate form. I am trying to make in an as exact replica of the original as possible. I have created the two forms, but I do not know enough about macros to make it work.

Thanks for the response

- Collapse -
The users should have ...
Apr 16, 2007 7:51AM PDT

both documents, and the macro in their normal.dot. That doesn't seem to be a good idea. I'd just give them two documents and instruction on when to use which. That's 2 shortcuts on their desktop.
You could write a vbs-script that lets them choose between the 2 documents, but I wonder if it's worth the trouble.

Kees