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

In my w/sheet I have number of calculated fields basing on formulas linkedto
this sheet as well as other sheets of same w/book.I have 3 macros also.I
would like to run a macro if a particular cell value in w/sheet changes.Say ,
If whenever I changescell G1 value macro1 should run.

--
Message posted via http://www.officekb.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,533
Default run macro on a condition

Hi TK

Use an event code to trap changes in your worksheet. This code will only
fire if you enter a value in your worksheet not if the change is due to a
calculation.

The code is to be pasted into the code sheet for the desired worksheet.

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$G$1" Then
Call Macro1
End If
End Sub

Regards,
Per

"tkraju via OfficeKB.com" <u16627@uwe skrev i meddelelsen
news:94bd2f6461e81@uwe...
In my w/sheet I have number of calculated fields basing on formulas
linkedto
this sheet as well as other sheets of same w/book.I have 3 macros also.I
would like to run a macro if a particular cell value in w/sheet
changes.Say ,
If whenever I changescell G1 value macro1 should run.

--
Message posted via http://www.officekb.com


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 109
Default run macro on a condition

I have datavalidation list In Cell G1, and the list is a named range of
different sheet.I have one macro that updates data every time.Ihave second
macro(w/sheet_change) which runs by changing cell value G1.when ever I am
changing cell value G1 ,the firstmacro is not running properly.
Per Jessen wrote:
Hi TK

Use an event code to trap changes in your worksheet. This code will only
fire if you enter a value in your worksheet not if the change is due to a
calculation.

The code is to be pasted into the code sheet for the desired worksheet.

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$G$1" Then
Call Macro1
End If
End Sub

Regards,
Per

In my w/sheet I have number of calculated fields basing on formulas
linkedto
this sheet as well as other sheets of same w/book.I have 3 macros also.I
would like to run a macro if a particular cell value in w/sheet
changes.Say ,
If whenever I changescell G1 value macro1 should run.


--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200904/1

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 109
Default run macro on a condition

Thank you Per Jessen,
It worked.Thank you so much...

Per Jessen wrote:
Hi TK

Use an event code to trap changes in your worksheet. This code will only
fire if you enter a value in your worksheet not if the change is due to a
calculation.

The code is to be pasted into the code sheet for the desired worksheet.

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$G$1" Then
Call Macro1
End If
End Sub

Regards,
Per

In my w/sheet I have number of calculated fields basing on formulas
linkedto
this sheet as well as other sheets of same w/book.I have 3 macros also.I
would like to run a macro if a particular cell value in w/sheet
changes.Say ,
If whenever I changescell G1 value macro1 should run.


--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200904/1

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 109
Default run macro on a condition

Hi Per
If I write like this will it work:
If Target.Address="$G$1" Or "$H$1" Then
I want to change any of two cells.


Per Jessen wrote:
Hi TK

Use an event code to trap changes in your worksheet. This code will only
fire if you enter a value in your worksheet not if the change is due to a
calculation.

The code is to be pasted into the code sheet for the desired worksheet.

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$G$1" Then
Call Macro1
End If
End Sub

Regards,
Per

In my w/sheet I have number of calculated fields basing on formulas
linkedto
this sheet as well as other sheets of same w/book.I have 3 macros also.I
would like to run a macro if a particular cell value in w/sheet
changes.Say ,
If whenever I changescell G1 value macro1 should run.


--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200904/1



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,533
Default run macro on a condition

Hi

You could use
If Target.address =="$G$1" Or Target.address "$H$1" Then

But I would use this as it is more flexible as it can be used on larger
ranges:

If Not Intersect(Target, Range("G1:H1") Is Nothing Then

-Per

"tkraju via OfficeKB.com" <u16627@uwe skrev i meddelelsen
news:94bdab5495bf9@uwe...
Hi Per
If I write like this will it work:
If Target.Address="$G$1" Or "$H$1" Then
I want to change any of two cells.


Per Jessen wrote:
Hi TK

Use an event code to trap changes in your worksheet. This code will only
fire if you enter a value in your worksheet not if the change is due to a
calculation.

The code is to be pasted into the code sheet for the desired worksheet.

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$G$1" Then
Call Macro1
End If
End Sub

Regards,
Per

In my w/sheet I have number of calculated fields basing on formulas
linkedto
this sheet as well as other sheets of same w/book.I have 3 macros also.I
would like to run a macro if a particular cell value in w/sheet
changes.Say ,
If whenever I changescell G1 value macro1 should run.


--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200904/1


  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 109
Default run macro on a condition

If Not Intersect(Target,Range("G1:H1") Is Nothing Then
this giving me error

Per Jessen wrote:
Hi

You could use
If Target.address =="$G$1" Or Target.address "$H$1" Then

But I would use this as it is more flexible as it can be used on larger
ranges:

If Not Intersect(Target, Range("G1:H1") Is Nothing Then

-Per

Hi Per
If I write like this will it work:

[quoted text clipped - 24 lines]
changes.Say ,
If whenever I changescell G1 value macro1 should run.


--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200904/1

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,533
Default run macro on a condition

The line miss a closing paranthesis:

If Not Intersect(Target,Range("G1:H1")) Is Nothing Then

-Per

"tkraju via OfficeKB.com" <u16627@uwe skrev i meddelelsen
news:94ce3eac73fe8@uwe...
If Not Intersect(Target,Range("G1:H1") Is Nothing Then
this giving me error

Per Jessen wrote:
Hi

You could use
If Target.address =="$G$1" Or Target.address "$H$1" Then

But I would use this as it is more flexible as it can be used on larger
ranges:

If Not Intersect(Target, Range("G1:H1") Is Nothing Then

-Per

Hi Per
If I write like this will it work:

[quoted text clipped - 24 lines]
changes.Say ,
If whenever I changescell G1 value macro1 should run.


--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200904/1


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 condition puiuluipui Excel Discussion (Misc queries) 5 November 13th 09 12:07 PM
I need a macro to run on a set condition Savuti Excel Programming 3 May 1st 08 04:05 PM
use more than 4 condition in cf without using macro Montu Excel Worksheet Functions 3 November 15th 07 03:19 PM
Run Macro until a condition is met tx12345[_12_] Excel Programming 2 February 14th 06 01:02 AM
macro to run only under certain condition - how? Orion[_2_] Excel Programming 2 December 22nd 04 10:08 AM


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