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 using the macro in Worksheet function

Hi,
I try to use the macro in one condition of "IF"
If(B1=4,Macro1,"not necessary")
I don't know if is posibile run Macro1.
somebody can help me ?

Thanks in advance.
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1,104
Default using the macro in Worksheet function

A function can do one thing: it can return a value
It cannot run a macro
best wishes
--
Bernard V Liengme
Microsoft Excel MVP
http://people.stfx.ca/bliengme
remove caps from email


"jannot" wrote in message
...
Hi,
I try to use the macro in one condition of "IF"
If(B1=4,Macro1,"not necessary")
I don't know if is posibile run Macro1.
somebody can help me ?

Thanks in advance.



  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 8,520
Default using the macro in Worksheet function

As Bernard mentioned the macro cannot be trigerred from a formula.
However you can make use of the worksheet change event to call the macro
when B4 is 4. Try the below. From sheet tabView code and paste the below
code...now if the value in B4 is entered as 4 macro1 is initiated.

Private Sub Worksheet_Change(ByVal Target As Range)
Application.EnableEvents = False
If Not Application.Intersect(Target, Range("B4")) Is Nothing Then
If Target.Value = 4 Then Call Macro1
End If
Application.EnableEvents = True
End Sub

If this post helps click Yes
---------------
Jacob Skaria


"jannot" wrote:

Hi,
I try to use the macro in one condition of "IF"
If(B1=4,Macro1,"not necessary")
I don't know if is posibile run Macro1.
somebody can help me ?

Thanks in advance.

  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 22,906
Default using the macro in Worksheet function

If B4 is a calculated value use

Private Sub Worksheet_Calculate() event instead of Change event.


Gord Dibben MS Excel MVP

On Tue, 4 Aug 2009 09:23:01 -0700, Jacob Skaria
wrote:

As Bernard mentioned the macro cannot be trigerred from a formula.
However you can make use of the worksheet change event to call the macro
when B4 is 4. Try the below. From sheet tabView code and paste the below
code...now if the value in B4 is entered as 4 macro1 is initiated.

Private Sub Worksheet_Change(ByVal Target As Range)
Application.EnableEvents = False
If Not Application.Intersect(Target, Range("B4")) Is Nothing Then
If Target.Value = 4 Then Call Macro1
End If
Application.EnableEvents = True
End Sub

If this post helps click Yes
---------------
Jacob Skaria


"jannot" wrote:

Hi,
I try to use the macro in one condition of "IF"
If(B1=4,Macro1,"not necessary")
I don't know if is posibile run Macro1.
somebody can help me ?

Thanks in advance.


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
worksheet function in event macro Ita Excel Worksheet Functions 3 May 25th 09 10:56 AM
calling worksheet function from a macro Joe Farruggio Excel Worksheet Functions 3 November 20th 06 10:01 PM
worksheet function vs macro [email protected] Excel Discussion (Misc queries) 2 June 13th 06 02:54 AM
macro or worksheet function? rc Excel Worksheet Functions 3 March 31st 06 04:26 AM
Sorting - Macro or worksheet function Danny Excel Worksheet Functions 1 August 2nd 05 09:17 PM


All times are GMT +1. The time now is 04:21 AM.

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"