Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 313
Default executing action only when cell has changed

I want to create code to run simple procedure only when the triggering cell
will change. I have tried all suggestions (Worksheet_Change event) found on
this newsgroup and nothing works for me. Please help.

I want the code:

For i = 3 To 14
Cells(4, i) = Cells(4, i - 1) + 7
Next i

to be executed only when the value in the cell B4 will be changed by user -
new value entered.

Thanks for help.

Tony
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default executing action only when cell has changed

"Tony" wrote in message
...
I want to create code to run simple procedure only when the triggering cell
will change. I have tried all suggestions (Worksheet_Change event) found
on
this newsgroup and nothing works for me. Please help.

I want the code:

For i = 3 To 14
Cells(4, i) = Cells(4, i - 1) + 7
Next i

to be executed only when the value in the cell B4 will be changed by
user -
new value entered.

Thanks for help.

Tony


Tony,

Would nesting a if then else condition in a do while loop be possible for
your code? For example:

i=0
do while i 3
if i 14 then
' "Exit 'cause you're done"
else
Cells(4, i) = Cells(4, i - 1) + 7
i=i+1
loop


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,337
Default executing action only when cell has changed

right click sheet tabview codeleft window select worksheetright window
select worksheet_change

if target.address < "$B$4" then exit sub
your code


--
Don Guillett
SalesAid Software

"Tony" wrote in message
...
I want to create code to run simple procedure only when the triggering

cell
will change. I have tried all suggestions (Worksheet_Change event) found

on
this newsgroup and nothing works for me. Please help.

I want the code:

For i = 3 To 14
Cells(4, i) = Cells(4, i - 1) + 7
Next i

to be executed only when the value in the cell B4 will be changed by

user -
new value entered.

Thanks for help.

Tony



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default executing action only when cell has changed

right click on the sheet tab, and select view code. paste in code like
this:

Private Sub Worksheet_Change(ByVal Target As Range)
Dim i As Long
On Error GoTo ErrHandler
If Target.Address = "$B$4" Then
Application.EnableEvents = False
For i = 3 To 14
Cells(4, i) = Cells(4, i - 1) + 7
Next i
End If
ErrHandler:
Application.EnableEvents = True
End Sub


this assumes the value of B4 will change because the cell is edited or it is
changed programmatically or it is updated by DDE.

If B4 contains a formula and that is what you want to react to, then you
would need to put the code in the calculate event.

However, why not just put the formula

=B4+7 in C4 and drag fill to the right.

--
Regards,
Tom Ogilvy


"Tony" wrote in message
...
I want to create code to run simple procedure only when the triggering

cell
will change. I have tried all suggestions (Worksheet_Change event) found

on
this newsgroup and nothing works for me. Please help.

I want the code:

For i = 3 To 14
Cells(4, i) = Cells(4, i - 1) + 7
Next i

to be executed only when the value in the cell B4 will be changed by

user -
new value entered.

Thanks for help.

Tony



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default executing action only when cell has changed

I completely agree with Tom, and I might add that it's a good practice to use
named ranges; they can make your life easier when you make changes to your
workbook.

"Tom Ogilvy" wrote:

right click on the sheet tab, and select view code. paste in code like
this:

Private Sub Worksheet_Change(ByVal Target As Range)
Dim i As Long
On Error GoTo ErrHandler
If Target.Address = "$B$4" Then
Application.EnableEvents = False
For i = 3 To 14
Cells(4, i) = Cells(4, i - 1) + 7
Next i
End If
ErrHandler:
Application.EnableEvents = True
End Sub


this assumes the value of B4 will change because the cell is edited or it is
changed programmatically or it is updated by DDE.

If B4 contains a formula and that is what you want to react to, then you
would need to put the code in the calculate event.

However, why not just put the formula

=B4+7 in C4 and drag fill to the right.

--
Regards,
Tom Ogilvy


"Tony" wrote in message
...
I want to create code to run simple procedure only when the triggering

cell
will change. I have tried all suggestions (Worksheet_Change event) found

on
this newsgroup and nothing works for me. Please help.

I want the code:

For i = 3 To 14
Cells(4, i) = Cells(4, i - 1) + 7
Next i

to be executed only when the value in the cell B4 will be changed by

user -
new value entered.

Thanks for help.

Tony




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
Excell copy action pauses for 15 second for the smallest action Meekal Excel Discussion (Misc queries) 1 January 28th 10 04:30 PM
Finding data and executing an action Excel Rookie247 Excel Discussion (Misc queries) 1 August 24th 09 11:37 PM
Format changed when the details in cell changed angel Excel Worksheet Functions 9 July 15th 08 12:36 AM
Executing a macro from a cell filo666 Excel Discussion (Misc queries) 2 February 15th 05 08:18 PM
executing a macro from within a cell kduntley Excel Programming 2 May 13th 04 05:38 PM


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