![]() |
How do I initiate a macro directly in a worksheet?
I would like to click on a cell and initiate a macro. Is it possible?
|
How do I initiate a macro directly in a worksheet?
All you need is a Command Button. Click on "View/Toolbars/Control Toolbox.
You will see, among others, the Command Button icon. Click it and click on the sheet where you want the button. When you double-click the button a Macro will be set up for you to place your code in. If you right-click the button and choose "Properties" you can change the Caption on it etc. -- Best wishes, Jim "AMMPro" wrote: I would like to click on a cell and initiate a macro. Is it possible? |
How do I initiate a macro directly in a worksheet?
Think your after Event Procedures. Attached is a link which has a demo of the code. The code is pasted into the sheet that the change occurs in and not module. http://www.cpearson.com/excel/events.htm VBA Noo -- VBA Noo ----------------------------------------------------------------------- VBA Noob's Profile: http://www.excelforum.com/member.php...fo&userid=3383 View this thread: http://www.excelforum.com/showthread.php?threadid=56178 |
How do I initiate a macro directly in a worksheet?
Hi AMMPro,
Try: '============= Private Sub Worksheet_SelectionChange(ByVal Target As Range) Dim rng As Range Set rng = Me.Range("A1") '<<==== CHANGE If Not Intersect(Target, rng) Is Nothing Then Call MyMacro End If End Sub '<<============= This is worksheet event code and should be pasted into the worksheets's code module (not a standard module and not the workbook's ThisWorkbook module): Right-click the worksheet's tab Select 'View Code' from the menu and paste the code. Alt-F11 to return to Excel. --- Regards, Norman "AMMPro" wrote in message ... I would like to click on a cell and initiate a macro. Is it possible? |
All times are GMT +1. The time now is 07:13 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com