Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
WAJ WAJ is offline
external usenet poster
 
Posts: 1
Default Can a Macro be run as part of an IF() statement

Can I run a macro as part of an IF statement i.e. IF(A2=1,Run Macro 1,Do
nothing ) I simplified what I want to happen but I want to automatically run
a macro when a condition goes true in another cell.
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 22,906
Default Can a Macro be run as part of an IF() statement

You cannot do it in a formula but event code could run the macro when A1=1

Private Sub Worksheet_Calculate()
On Error GoTo stoppit
Application.EnableEvents = False
With Me.Range("A1")
If .Value = 1 Then
'MsgBox "Please be advised that A1 is equal to 1"
Macroname
End If
End With
stoppit:
Application.EnableEvents = True
End Sub


Gord Dibben MS Excel MVP


On Thu, 4 Oct 2007 20:15:01 -0700, WAJ wrote:

Can I run a macro as part of an IF statement i.e. IF(A2=1,Run Macro 1,Do
nothing ) I simplified what I want to happen but I want to automatically run
a macro when a condition goes true in another cell.


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
Macro Execution, Part Duo C Brandt Excel Discussion (Misc queries) 1 July 12th 07 10:57 PM
how do I read this part of a vlookup statement !1:65536,12,FALSE TJPimpact Excel Discussion (Misc queries) 1 January 11th 07 09:03 PM
Replace Old Part Numbers with New Part Numbers in a Macro. Jeffery Keown Excel Discussion (Misc queries) 5 October 17th 06 03:45 PM
Can I create an IF statement that looks for part of a string of te Josh Craig Excel Worksheet Functions 2 June 19th 06 08:23 AM
need macro to check part# and sum jg53 Excel Worksheet Functions 8 April 13th 06 04:29 PM


All times are GMT +1. The time now is 12:22 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"