Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Macro with in a formula

Can a macro be run from with in a formula? If so how is it
started from with in the formula? If a macro can not be
run from within the formula can it be automaticaly
triggered an entry in a cell?
Thank you
Howard
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Macro with in a formula

Howard,

A function, including a UDF, can be run from within a formula, but these
functions can't amend the properties of any cells, and are really only
useful to return a value.

If you want to update other cells, you need VBA event code.

--

HTH

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

"Howard" wrote in message
...
Can a macro be run from with in a formula? If so how is it
started from with in the formula? If a macro can not be
run from within the formula can it be automaticaly
triggered an entry in a cell?
Thank you
Howard



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 391
Default Macro with in a formula

use the sheet's CHANGE event. This is fired when a new
value is entered into a cell. It is not fired when a
cell's value changes as a result of a formula.
Right click the sheet tab and select view code.
In the object dropdown( upper left corner) where you see
(General), select Worksheet.
The code automatically frames in the SelectionChange
method as this is the default. You can ignore this.
From the declarations dropdown(upper right) that now
shows 'SelectionChange' choose 'Change' and the following
code will be added:

Private Sub Worksheet_Change(ByVal Target As Range)

End Sub


Target is the cell whose value changed
You can now add code to call a procedure ( or macro by
another name), for example..

Private Sub Worksheet_Change(ByVal Target As Range)
Select Case True
Case Not (IsNumeric(Target.Value))
'do nothing
Case Target.Value <= 0
MsgBox " enter a number greater than 0"
Case Target.Value 5
MsgBox " enter a number less than 6"
Case Else
End Select

End Sub

HTH
Patrick MOlloy
Microsoft Excel MVP

-----Original Message-----
Can a macro be run from with in a formula? If so how is

it
started from with in the formula? If a macro can not be
run from within the formula can it be automaticaly
triggered an entry in a cell?
Thank you
Howard
.

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
Formula or Macro Eán[_2_] Excel Worksheet Functions 1 May 5th 09 12:21 PM
Need a formula/Macro Srikanth Excel Discussion (Misc queries) 3 March 27th 08 10:58 AM
Formula or Macro Meadowlark Excel Discussion (Misc queries) 5 February 27th 08 03:59 PM
Formula Macro Secret Squirrel Excel Discussion (Misc queries) 7 January 27th 07 04:16 PM
Macro Formula Corey Excel Discussion (Misc queries) 1 February 4th 06 06:13 PM


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