Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Can you use an IF statement to launch a macro?

Is it possible to use an IF statement in cell b1 to launch a desired
macro if a1 equals the value specified in the IF statement?

ie say IF a1 = "ABC" then the IF statement in b1 would recognise this
and launch macro1?

Does anyone know if this is possible or impossible? It would be
fantastic to learn that its possible!!!


---
Message posted from http://www.ExcelForum.com/

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Can you use an IF statement to launch a macro?

No!

You could use worksheet event code though

Private Sub Worksheet_Change(ByVal Target As Range)

If Target.Address(False, False) = "A1" Then
If Target.Value = "ABC" Then
macro1
End If
End If

End Sub

This would go into the worksheet code module


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"ian123 " wrote in message
...
Is it possible to use an IF statement in cell b1 to launch a desired
macro if a1 equals the value specified in the IF statement?

ie say IF a1 = "ABC" then the IF statement in b1 would recognise this
and launch macro1?

Does anyone know if this is possible or impossible? It would be
fantastic to learn that its possible!!!


---
Message posted from http://www.ExcelForum.com/



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Can you use an IF statement to launch a macro?

Sure. You can. Let's create the following two simple macros. One is custom worksheet function, the second on the a subroutine which pops up a msgbox

Function testing(
hello_macr
End Functio

Sub hello_macro(
MsgBox "hello
End Su

In cell B1, you type the following formula
=IF(A1="ABC",testing(),""

Change cell A1 to see the effect


----- ian123 wrote: ----

Is it possible to use an IF statement in cell b1 to launch a desire
macro if a1 equals the value specified in the IF statement

ie say IF a1 = "ABC" then the IF statement in b1 would recognise thi
and launch macro1

Does anyone know if this is possible or impossible? It would b
fantastic to learn that its possible!!


--
Message posted from http://www.ExcelForum.com


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Can you use an IF statement to launch a macro?

Just be advised that you would be restricted to many severe limitations
imposed on code called from a cell.

Also, as long as the condition is met, each time there was a calculate, the
code would be executed.

--
Regards,
Tom Ogilvy


Edwin Tam wrote in message
...
Sure. You can. Let's create the following two simple macros. One is custom

worksheet function, the second on the a subroutine which pops up a msgbox.

Function testing()
hello_macro
End Function

Sub hello_macro()
MsgBox "hello"
End Sub

In cell B1, you type the following formula:
=IF(A1="ABC",testing(),"")

Change cell A1 to see the effect.



----- ian123 wrote: -----

Is it possible to use an IF statement in cell b1 to launch a desired
macro if a1 equals the value specified in the IF statement?

ie say IF a1 = "ABC" then the IF statement in b1 would recognise this
and launch macro1?

Does anyone know if this is possible or impossible? It would be
fantastic to learn that its possible!!!


---
Message posted from http://www.ExcelForum.com/




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
Auto Launch of Macro Daren Excel Discussion (Misc queries) 1 March 20th 07 08:10 PM
Macro to launch web page hutchie Excel Discussion (Misc queries) 2 May 17th 06 05:30 PM
Automatically launch a macro when a fil is opened One-Leg Excel Discussion (Misc queries) 1 December 15th 04 08:12 PM
auto-launch a MACRO? d-cubed Excel Programming 4 December 22nd 03 10:10 PM
Launch Macro in Access via Macro running in Excel??? dgrant Excel Programming 1 September 24th 03 01:38 PM


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