Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default is it possible to run a macro using a cell reference?

TIA - everyone that helps in this group is awesome. thanks so much
for your help.


i would like to know, and i can't find it in my books, if it is
possible to run a macro when a cell returns a certain criteria.

for example, if range("A1") = x then application.run "macro1"

if so, where do i put the code?

jasonk
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,124
Default is it possible to run a macro using a cell reference?

right click sheet tabview codeinsert thisSAVE
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$A$1" And UCase(Target) = "X" Then MsgBox "HI"
End Sub

--
Don Guillett
SalesAid Software

"JasonK" wrote in message
...
TIA - everyone that helps in this group is awesome. thanks so much
for your help.


i would like to know, and i can't find it in my books, if it is
possible to run a macro when a cell returns a certain criteria.

for example, if range("A1") = x then application.run "macro1"

if so, where do i put the code?

jasonk



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default is it possible to run a macro using a cell reference?

What will make the value change?

If by editing use the Worksheet_Change event
if by formula, use the Worksheet_Calculate event

You get to these by right clicking on the sheet tab and selecting view code.

In the resulting module, in the dropdowns at the top
Left: Worksheet
Right: Change (or Calculate)

this places an event procedure definition in the module.

In the Change event, the Target argument contains a reference to the cell
that triggered the change (was edited usually). Calculate doesn't give you
that information.

Any cell that is changed by editing will trigger the Change event. So in
the event, you put code to determine whether to react or not

With calculate, you will need to determine whether you need to act or not.
If it is something to do over and over, then no problem. But if you only
want to do it once when the value changes, you will need to store information
- perhaps in static variables.

See Chip Pearson's page on events:

http://www.cpearson.com/excel/events.htm

--
Regards,
Tom Ogilvy

"JasonK" wrote:

TIA - everyone that helps in this group is awesome. thanks so much
for your help.


i would like to know, and i can't find it in my books, if it is
possible to run a macro when a cell returns a certain criteria.

for example, if range("A1") = x then application.run "macro1"

if so, where do i put the code?

jasonk

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default is it possible to run a macro using a cell reference?

thank you gentlemen, i appreciate the help.
the first code didn't work for me, but after reading this response,
i'm messing around with the advice and i believe i can make it work.

thanks again,
jasonk


On Fri, 17 Mar 2006 14:10:27 -0800, Tom Ogilvy
wrote:

What will make the value change?

If by editing use the Worksheet_Change event
if by formula, use the Worksheet_Calculate event

You get to these by right clicking on the sheet tab and selecting view code.

In the resulting module, in the dropdowns at the top
Left: Worksheet
Right: Change (or Calculate)

this places an event procedure definition in the module.

In the Change event, the Target argument contains a reference to the cell
that triggered the change (was edited usually). Calculate doesn't give you
that information.

Any cell that is changed by editing will trigger the Change event. So in
the event, you put code to determine whether to react or not

With calculate, you will need to determine whether you need to act or not.
If it is something to do over and over, then no problem. But if you only
want to do it once when the value changes, you will need to store information
- perhaps in static variables.

See Chip Pearson's page on events:

http://www.cpearson.com/excel/events.htm


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 using a cell reference Jason Falzon[_2_] Excel Discussion (Misc queries) 3 March 24th 10 04:16 PM
Cell Reference Macro Scott Excel Discussion (Misc queries) 3 June 16th 09 04:13 PM
cell reference using macro Alex Martinez Excel Programming 2 September 15th 05 09:06 AM
Macro cell reference help justaguyfromky Excel Programming 9 January 8th 05 05:43 PM
run a macro from a cell reference spence[_3_] Excel Programming 2 December 9th 03 09:36 PM


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