Assign macro to whole page

swaink

Active Member
Joined
Feb 15, 2002
Messages
432
Hi Everyone

One question is it possible to set up a worksheet, so that if a user clicks anywhere on the sheet it activates a macro.

I'm looking to have a sheet the user can view only and print it off if they wish.

Best regards

Kevin
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
Hi Kevin

Try something like this event macro

Right click sheet tab, left click View Code and paste this code into the white area.
Change "name of your macro" to the one you want to run (retain the quote marks)


Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Answer = InputBox("Do you want to print this page? Type YES OR NO")
If Answer = "YES" Then Application.Run "name of your macro"
End Sub

Regards
Derek
 
Upvote 0

Forum statistics

Threads
1,213,536
Messages
6,114,207
Members
448,554
Latest member
Gleisner2

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top