Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
davidhub
 
Posts: n/a
Default how to run a macro from a formula?

I need to define a formula to run a predefined macro as a result of a logical
comparision. Please help.
  #2   Report Post  
Tom Ogilvy
 
Posts: n/a
Default

You can make you macro a function and then use it in your formula. Be aware
that macros used in this fashion can only return a value to the cell
containing the function - they can not format cells, change values in cells
or otherwise alter the Excel environment.

--
Regards,
Tom Ogilvy

"davidhub" wrote in message
...
I need to define a formula to run a predefined macro as a result of a

logical
comparision. Please help.



  #3   Report Post  
moi
 
Posts: n/a
Default

Add a function and put that in your worksheet IF-statement, like:

Public Function cellFunctionFirst(cellText As String) As String
Call thenModule(cellText)
cellFunctionFirst = cellText
End Function

Private Sub thenModule(cellText As String)
cellText = cellText & " text string added by macro."
End Sub

From the function call the module and do the work there.
Only thing is, that a function always gives back a value and you might not
want that. So then it's better to add a worksheet event that keeps listening
and launches another more macro (or not) after your function changed a cell
with a certain result.



"davidhub" schreef in bericht
...
I need to define a formula to run a predefined macro as a result of a
logical
comparision. Please help.



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
Formula checking multiple worksheets sonic-the-mouse Excel Worksheet Functions 2 June 5th 05 07:48 PM
Insert macro into formula Paul Excel Worksheet Functions 1 May 12th 05 08:25 PM
Creating a check mark box MarthaSue Setting up and Configuration of Excel 18 April 28th 05 12:31 AM
Problem with VBA returning the contents of a long formula. [email protected] Excel Discussion (Misc queries) 2 February 23rd 05 12:14 AM
Fill Formula - Macro Cathy U Excel Discussion (Misc queries) 2 February 22nd 05 04:48 PM


All times are GMT +1. The time now is 11:45 PM.

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

About Us

"It's about Microsoft Excel"