Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default macro auto run

is it possible to have a macro run automatically using an "if" statemen


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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default macro auto run

If you mean an IF statement in a worksheet, then no. Worksheets can only
call functions that return a result, they cannot run a macro that modifies
the Excel environment.

--

HTH

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

"nightshift12 " wrote in
message ...
is it possible to have a macro run automatically using an "if" statement
?


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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 923
Default macro auto run

In VBA you can choose which macro to run using any of the conditional
statements, so

If condition then
Call macro1
else
Call macro2
endif

of more simply for just one macro

If condition then call macro1

Cheers
Nigel

"nightshift12 " wrote in
message ...
is it possible to have a macro run automatically using an "if" statement
?


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



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 391
Default macro auto run

If is a conditional test, and can be in a sheet function
or in code.
In a sheet function, only the content of the calling cell
can be changed - a sheet function cannot alter th evalues
in other cells.

In code, your IF can be in a procedure - sub if you will-
where the called routine can pretty much do whatever you
want.

Now, running a macro automatically means what? If yuo
want code to start when a workbook opens, then use a proc
called Auto_Open or use the workboook's Open event.
If you want code to run when a cell value changes, then
you coul duse the Sheet's Change event - this is fired
when a value is entered. ou could also use the workbook's
SheetCalculate event that is fired when a sheet is
calculated.

Patrick Molloy
Microsoft Excel MVP


-----Original Message-----
is it possible to have a macro run automatically using

an "if" statement
?


---
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 run macro Esradekan Excel Worksheet Functions 5 August 31st 08 11:58 PM
Sub Macro vrs Function Macro Auto Start Pat Excel Discussion (Misc queries) 7 June 6th 07 09:53 PM
Macro Help Needed - Excel 2007 - Print Macro with Auto Sort Gavin Excel Worksheet Functions 0 May 17th 07 01:20 PM
Macro Auto Run(2) Gary Excel Worksheet Functions 4 May 18th 06 09:07 AM
Macro - Auto Run Gary Excel Worksheet Functions 1 May 12th 06 08:29 PM


All times are GMT +1. The time now is 03:06 AM.

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"