Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 186
Default how can i use an if statement to run a macro?

if ( a1 = 1, run macro, " ")

what code do i need to use to do this?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 983
Default how can i use an if statement to run a macro?

Insert this code into your sheet and you should be good to go.

Option Explicit

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$A$1" And Target.Value = 1 Then
Call MyMacro 'Insert the name of your macro here
End If
End Sub

To add this to a sheet right click on the sheet tab - select view code
-paste

HTH

"Jack" wrote:

if ( a1 = 1, run macro, " ")

what code do i need to use to do this?

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 863
Default how can i use an if statement to run a macro?

Are you talkong about a worksheet formula that looks like what you posted? If
so, you can't "run a macro" that carries out actions on the worksheet.

The "macro" can only be a VBA function that returns a value to the cell, just
like SUM or AVERAGE do.


On Thu, 3 Mar 2005 15:29:03 -0800, "Jack"
wrote:

if ( a1 = 1, run macro, " ")

what code do i need to use to do this?


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 if and / or statement orquidea Excel Discussion (Misc queries) 4 April 4th 23 10:27 AM
IF statement in macro Aline Excel Worksheet Functions 4 September 30th 08 07:40 PM
can i use an IF Statement to run a macro? Davidrowland88 Excel Worksheet Functions 2 February 11th 05 12:45 PM
HELP w/ Macro and IF Statement randy_tn Excel Programming 1 November 3rd 04 01:49 AM
If-statement in Macro fabalicious[_25_] Excel Programming 1 October 8th 04 08:40 AM


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