Hyperlink to exit Excel

  • Thread starter Thread starter Pimamedic
  • Start date Start date
P

Pimamedic

Is there a way in Excel 2002 to make a link so that one click will close the
program, take me to the exit routine?

Thank you
 
Click on cell A1 in Sheet2 and:

Insert > Hyperlink > to a place in this document

This will create a hyperlink to itself. Then in the worksheet code area,
insert the following:

Private Sub Worksheet_FollowHyperlink(ByVal Target As Hyperlink)
If Target.Parent = "Sheet2!A1" Then
Application.Quit
End If
End Sub
 
Because it is worksheet code, it is very easy to install and use:

1. right-click the tab name near the bottom of the window
2. select View Code - this brings up a VBE window
3. paste the stuff in and close the VBE window

If you save the workbook, the macro will be saved with it.

To remove the macro:

1. bring up the VBE windows as above
2. clear the code out
3. close the VBE window

To learn more about macros in general, see:

http://www.mvps.org/dmcritchie/excel/getstarted.htm

To learn more about Event Macros (worksheet code), see:

http://www.mvps.org/dmcritchie/excel/event.htm
 
Great TY

Gary''s Student said:
Because it is worksheet code, it is very easy to install and use:

1. right-click the tab name near the bottom of the window
2. select View Code - this brings up a VBE window
3. paste the stuff in and close the VBE window

If you save the workbook, the macro will be saved with it.

To remove the macro:

1. bring up the VBE windows as above
2. clear the code out
3. close the VBE window

To learn more about macros in general, see:

http://www.mvps.org/dmcritchie/excel/getstarted.htm

To learn more about Event Macros (worksheet code), see:

http://www.mvps.org/dmcritchie/excel/event.htm
 
Can I change the code to read
Private Sub Worksheet_FollowHyperlink(ByVal Target As Hyperlink)
If I make the hyperlink to G7 in sheet 1
 
If I put the hyperlink in sheet 1 G7 as opposed to Sheet 2 A1 and chnage the
code to G7 it does not work. If I leave it as originally planned in sheet2 A1
then it works.
I am trying to make this as simple as possible for folks who are nto
computer illiterate. Or at lewast less then I am. If I can out the code to
exit the program in sheet 1 cell g7 is a convient cell.

THANKS
 
Back
Top