Archive of Mr Excel Message Board
Back to Excel VBA archive index
Back to archive home
Running a Macro from a formulaPosted by David Merikansky on December 10, 2001 9:59 AM
Hi, I'm trying to run a macro from a formula, in which I allready wrote the macro and I can either run it by pressing a button or by pressing the assigned ctrl key. Wwhat I want to do is something like this in C1:
Is there any way I can do it? thanks in advance.
I would appreciate if you can write me an e-mail with your suggestions.
|Check out our Excel VBA Resources
Re: Running a Macro from a formulaPosted by Dan on December 10, 2001 10:19 AM
You can't do it from a formula on a worksheet. You have to do it from VBA. Insert this in the your code under the "ThisWorkbook" project, and it should work the way you want.
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Excel.Range)
If Target.Address = "$B$1" Then
If Range("B1") = Range("A1") Then InsertNameOfMacroHere
Re: Running a Macro from a formulaPosted by David on December 10, 2001 4:06 PM
Unfurtunally, This didn't work, but I do apreciate your kindness Dan... any other sugestions???
What about it doesn't work?Posted by Bariloche on December 10, 2001 5:38 PM
What aspect of it didn't work?
Have you checked the scope of the macro that you're calling to make sure its visible to the SelectionChange event macro? What error was generated?
I haven't delved into this, but the solution that Dan posted is substantially the same as what I would have posted.
This archive is from the original message board at www.MrExcel.com.
All contents © 1998-2004 MrExcel.com.
Visit our online store
to buy searchable CD's with thousands of VBA and Excel answers.
Microsoft Excel is a registered trademark of the Microsoft Corporation.
MrExcel is a registered trademark of Tickling Keys, Inc.