Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1
Default Running a Macro from a Spreadsheet Function

Does anyone know a method of calling/running a macro from within a cell
function (e.g. a logical IF function)? I am currently using XP Office with
Excel 2002.
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 22,906
Default Running a Macro from a Spreadsheet Function

You can't run a macro from an Excel IF function.

You may be able to run a macro from event code that is triggered by the results
of an IF calculation.

More details would be in order but here is sample sheet event code that runs on
the results of an IF

A1 fomula is =B1 * C1

Private Sub Worksheet_Calculate()
On Error GoTo stoppit
Application.EnableEvents = False
With Me.Range("A1")
If .Value < 144 Then
MsgBox "Please be advised that A1 does not equal the correct amount."
'Call "your macro name" to be used instead of the msgbox
End If
End With
stoppit:
Application.EnableEvents = True
End Sub


Gord Dibben MS Excel MVP




On Sat, 9 Feb 2008 16:19:00 -0800, Patrick (GVC) <Patrick
wrote:

Does anyone know a method of calling/running a macro from within a cell
function (e.g. a logical IF function)? I am currently using XP Office with
Excel 2002.


  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 524
Default Running a Macro from a Spreadsheet Function

Sat, 9 Feb 2008 16:19:00 -0800 from <?B?UGF0cmljayAoR1ZDKQ==?
= <Patrick :
Does anyone know a method of calling/running a macro from within a cell
function (e.g. a logical IF function)? I am currently using XP Office with
Excel 2002.


Make it a user-defined function. As far as I know, a function can
contain any code that you could put into a macro.

--
Stan Brown, Oak Road Systems, Tompkins County, New York, USA
http://OakRoadSystems.com
A: Maybe because some people are too annoyed by top posting.
Q: Why do I not get an answer to my question(s)?
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Looking for a macro/function in an excel spreadsheet (Help) Keith (Southend) Excel Worksheet Functions 6 January 28th 07 12:19 PM
Running a Macro that enters a function that returns #VALUE! gevew Excel Discussion (Misc queries) 3 December 29th 06 08:34 PM
disable user running macro from Tools Macro Steve Simons Excel Discussion (Misc queries) 4 September 28th 06 06:28 AM
How can I invoke running a macro from within an "IF" function. ron Excel Worksheet Functions 11 February 8th 06 03:35 PM
Prevent A Macro From Running If SpreadSheet is Filtered carl Excel Worksheet Functions 1 June 22nd 05 04:04 PM


All times are GMT +1. The time now is 02:36 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"