Command buttons

G

Guest

I am very new to Excel and VBA. We are a small company with a large server
with documents everywhere that are hard to find. I have been tasked with
updating a workbook that was created in 1999 which provides a "house" for
various hyperlinks to the server to get documents. In order to jump from
workbook to workbook, there are command buttons on the worksheets and each
has a macro assigned to it to take it to another sheet or back to the main
sheet.

I have updated the hyperlinks in a new workbook, and created a userform with
command buttons and have managed to get the userform to open when the
workbook is opened.

How do I get all these command buttons to take me to the various sheets
which contain the hyperlinks to the documents on the server. I have four
sheets - Computer Information, Files, Office Information and Employee
Benefits. Then, once I am on one of the four sheets, how do I put a command
button on a worksheet that can take them back to the userform with all the
command buttons on it?

Thanks so much for your help.
 
J

johncassell

Hello,

Hope I have read what you need right...

If you are just looking for command buttons then right click somewher
to the right of your help menu in Excel to bring a menu. Then choos
forms, select the rectangle one named "Button" and then drag to th
sheet - it will automatically ask which macro this refers to and thi
is where you choose either your "Back to last spreadsheet macro" or th
"Send me to the hyperlink spreadsheet one".

Hope this helps.

Joh
 
G

Guest

Thanks, I have the forms toolbar open, but I can't seem to get a command
button dragged to the form. Is there a trick to this? Then, once I get the
button onto the worksheet, can I assign some code to it to bring up the
userform that I created in VB?
 
J

johncassell

Make sure that the forms toolbar is open in Excel (not VB, just so we
know we are on the same page - the button in the top right of the
toolbar should be "Aa") and then you just click the rectangle button
(your cursor will change to a cross) then click where you want it on
your sheet. As soon as you choose where to place it you will be asked
to provide the macro which the button will call.

You can skip this by pressing ESC and then if you want to assign a
macro to it later just right-click the button and select "Assign
Macro".

You can resize it or move it by rightclicking then pressing ESC then
drag/resize it.

John
 
G

Guest

Ok, I did it! I have the button on the sheet. Now, I have created a user
form in VBA, I want this button to open that form. Can I write a macro to do
that? I can't find the form unless I go Visual Basic window. There, it is
under forms.

Once I get the button on my sheet to pull up this form, I have VB
commandbuttons on the user form that I want to pull up worksheets when you
click them. Can I assign macros to those buttons ( those are VB buttons, not
form buttons).

Thanks so much!
 
J

johncassell

create a macro like the following

Sub ShowForm()
UserForm1.show
End Sub

Where Userform1 is the name of the form you want to load.
John
 
J

johncassell

If you want to run macros from the buttons on your form then do the
following:

On the userform, click (the button you want to run a macro from) once
and in the properties box (in the bottom left of the screen) you will
see the name of that button. Lets say its called OpenFinanceSheet..

So then double-click that button to open the code page and paste this
in

Private Sub OpenFinanceSheet_click()

Put your macro code in here

End Sub

John
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top