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

useing event to trigger then after a code is run to come back and change
trigger value trigger. value is 10 want to change it to 10 after runnung
procedure. can we do this?
Thanks

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default event question

A very good question. The event code needs to remember the previous value of
some variable.

Declare a static variable in a standard module above any subs or functions
in that module. The event code can reference that variable and update its
value as necessary.
--
Gary''s Student
gsnu200710


"Curt" wrote:

useing event to trigger then after a code is run to come back and change
trigger value trigger. value is 10 want to change it to 10 after runnung
procedure. can we do this?
Thanks

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default event question

Private Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo errhandler
Application.EnableEvents = False
If Target.column = 12 and Target.row 1 then
set rng = Range(Range("L1"),Target)
if Application.Countblank(rng) 0 then
msgbox "Don't leave any blank cells
target.clearcontents
target.end(xlup).offset(1,0).Select
Application.EnableEvents = True
exit sub
end if

If Target.Column = 12 And _
Target.Value 10 And _
IsNumeric(Target.Value) Then
Call CopyDonors(Target)
Target.Value = 10 '< change the value after calling
the sub
elseif Target.Column = 12 And _
Target.Value <= 0 Then
Call Copycomp(Target)
end if
end if
Application.EnableEvents = True
Exit Sub
errhandler:
Application.EnableEvents = True
End Sub

--
Regards,
Tom Ogilvy

"Curt" wrote:

useing event to trigger then after a code is run to come back and change
trigger value trigger. value is 10 want to change it to 10 after runnung
procedure. can we do this?
Thanks

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 469
Default event question

thanks much see how we do will print and compare to see if I can understand
Learning is fun
Thanks Again "Tom"

"Tom Ogilvy" wrote:

Private Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo errhandler
Application.EnableEvents = False
If Target.column = 12 and Target.row 1 then
set rng = Range(Range("L1"),Target)
if Application.Countblank(rng) 0 then
msgbox "Don't leave any blank cells
target.clearcontents
target.end(xlup).offset(1,0).Select
Application.EnableEvents = True
exit sub
end if

If Target.Column = 12 And _
Target.Value 10 And _
IsNumeric(Target.Value) Then
Call CopyDonors(Target)
Target.Value = 10 '< change the value after calling
the sub
elseif Target.Column = 12 And _
Target.Value <= 0 Then
Call Copycomp(Target)
end if
end if
Application.EnableEvents = True
Exit Sub
errhandler:
Application.EnableEvents = True
End Sub

--
Regards,
Tom Ogilvy

"Curt" wrote:

useing event to trigger then after a code is run to come back and change
trigger value trigger. value is 10 want to change it to 10 after runnung
procedure. can we do this?
Thanks



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 469
Default event question

set rng error requires object not familar with this. code is option explict
Thanks

"Tom Ogilvy" wrote:

Private Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo errhandler
Application.EnableEvents = False
If Target.column = 12 and Target.row 1 then
set rng = Range(Range("L1"),Target)
if Application.Countblank(rng) 0 then
msgbox "Don't leave any blank cells
target.clearcontents
target.end(xlup).offset(1,0).Select
Application.EnableEvents = True
exit sub
end if

If Target.Column = 12 And _
Target.Value 10 And _
IsNumeric(Target.Value) Then
Call CopyDonors(Target)
Target.Value = 10 '< change the value after calling
the sub
elseif Target.Column = 12 And _
Target.Value <= 0 Then
Call Copycomp(Target)
end if
end if
Application.EnableEvents = True
Exit Sub
errhandler:
Application.EnableEvents = True
End Sub

--
Regards,
Tom Ogilvy

"Curt" wrote:

useing event to trigger then after a code is run to come back and change
trigger value trigger. value is 10 want to change it to 10 after runnung
procedure. can we do this?
Thanks

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 469
Default event question

took care of error problem. Have a conflict with copydonors. When code in
place copy donors does not copy as before. Also code when you hit enter on
target cell returns you to next line and column 'B'

"Tom Ogilvy" wrote:

Private Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo errhandler
Application.EnableEvents = False
If Target.column = 12 and Target.row 1 then
set rng = Range(Range("L1"),Target)
if Application.Countblank(rng) 0 then
msgbox "Don't leave any blank cells
target.clearcontents
target.end(xlup).offset(1,0).Select
Application.EnableEvents = True
exit sub
end if

If Target.Column = 12 And _
Target.Value 10 And _
IsNumeric(Target.Value) Then
Call CopyDonors(Target)
Target.Value = 10 '< change the value after calling
the sub
elseif Target.Column = 12 And _
Target.Value <= 0 Then
Call Copycomp(Target)
end if
end if
Application.EnableEvents = True
Exit Sub
errhandler:
Application.EnableEvents = True
End Sub

--
Regards,
Tom Ogilvy

"Curt" wrote:

useing event to trigger then after a code is run to come back and change
trigger value trigger. value is 10 want to change it to 10 after runnung
procedure. can we do this?
Thanks

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default event question

Curt,
without having the spread sheet in front of me and knowing what you are
trying to do, the best I can do is try to give you some ideas. That is what
I attempted to do.

--
Regards,
Tom Ogilvy






"Curt" wrote:

took care of error problem. Have a conflict with copydonors. When code in
place copy donors does not copy as before. Also code when you hit enter on
target cell returns you to next line and column 'B'

"Tom Ogilvy" wrote:

Private Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo errhandler
Application.EnableEvents = False
If Target.column = 12 and Target.row 1 then
set rng = Range(Range("L1"),Target)
if Application.Countblank(rng) 0 then
msgbox "Don't leave any blank cells
target.clearcontents
target.end(xlup).offset(1,0).Select
Application.EnableEvents = True
exit sub
end if

If Target.Column = 12 And _
Target.Value 10 And _
IsNumeric(Target.Value) Then
Call CopyDonors(Target)
Target.Value = 10 '< change the value after calling
the sub
elseif Target.Column = 12 And _
Target.Value <= 0 Then
Call Copycomp(Target)
end if
end if
Application.EnableEvents = True
Exit Sub
errhandler:
Application.EnableEvents = True
End Sub

--
Regards,
Tom Ogilvy

"Curt" wrote:

useing event to trigger then after a code is run to come back and change
trigger value trigger. value is 10 want to change it to 10 after runnung
procedure. can we do this?
Thanks

  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 469
Default event question

You do a good job with out all the facts will try to include spread sheet
I sure do appreciate all of your help Will not let me paste spreadsheet so
you can see. Data sheet has all code in sheetchange event. when it runs copy
donors it pastes into donors sheet needed info then it sets target to 10. all
sheets are in same workbook
Is there a way to send spreadsheet? Will try to modify as best this guy can
Thanks Much




"Tom Ogilvy" wrote:

Curt,
without having the spread sheet in front of me and knowing what you are
trying to do, the best I can do is try to give you some ideas. That is what
I attempted to do.

--
Regards,
Tom Ogilvy






"Curt" wrote:

took care of error problem. Have a conflict with copydonors. When code in
place copy donors does not copy as before. Also code when you hit enter on
target cell returns you to next line and column 'B'

"Tom Ogilvy" wrote:

Private Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo errhandler
Application.EnableEvents = False
If Target.column = 12 and Target.row 1 then
set rng = Range(Range("L1"),Target)
if Application.Countblank(rng) 0 then
msgbox "Don't leave any blank cells
target.clearcontents
target.end(xlup).offset(1,0).Select
Application.EnableEvents = True
exit sub
end if

If Target.Column = 12 And _
Target.Value 10 And _
IsNumeric(Target.Value) Then
Call CopyDonors(Target)
Target.Value = 10 '< change the value after calling
the sub
elseif Target.Column = 12 And _
Target.Value <= 0 Then
Call Copycomp(Target)
end if
end if
Application.EnableEvents = True
Exit Sub
errhandler:
Application.EnableEvents = True
End Sub

--
Regards,
Tom Ogilvy

"Curt" wrote:

useing event to trigger then after a code is run to come back and change
trigger value trigger. value is 10 want to change it to 10 after runnung
procedure. can we do this?
Thanks

  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default event question

Not to the group.



if you want me to look at it.



--
Regards,
Tom Ogilvy

"Curt" wrote in message
...
You do a good job with out all the facts will try to include spread sheet
I sure do appreciate all of your help Will not let me paste spreadsheet so
you can see. Data sheet has all code in sheetchange event. when it runs
copy
donors it pastes into donors sheet needed info then it sets target to 10.
all
sheets are in same workbook
Is there a way to send spreadsheet? Will try to modify as best this guy
can
Thanks Much




"Tom Ogilvy" wrote:

Curt,
without having the spread sheet in front of me and knowing what you are
trying to do, the best I can do is try to give you some ideas. That is
what
I attempted to do.

--
Regards,
Tom Ogilvy






"Curt" wrote:

took care of error problem. Have a conflict with copydonors. When code
in
place copy donors does not copy as before. Also code when you hit enter
on
target cell returns you to next line and column 'B'

"Tom Ogilvy" wrote:

Private Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo errhandler
Application.EnableEvents = False
If Target.column = 12 and Target.row 1 then
set rng = Range(Range("L1"),Target)
if Application.Countblank(rng) 0 then
msgbox "Don't leave any blank cells
target.clearcontents
target.end(xlup).offset(1,0).Select
Application.EnableEvents = True
exit sub
end if

If Target.Column = 12 And _
Target.Value 10 And _
IsNumeric(Target.Value) Then
Call CopyDonors(Target)
Target.Value = 10 '< change the value after
calling
the sub
elseif Target.Column = 12 And _
Target.Value <= 0 Then
Call Copycomp(Target)
end if
end if
Application.EnableEvents = True
Exit Sub
errhandler:
Application.EnableEvents = True
End Sub

--
Regards,
Tom Ogilvy

"Curt" wrote:

useing event to trigger then after a code is run to come back and
change
trigger value trigger. value is 10 want to change it to 10 after
runnung
procedure. can we do this?
Thanks





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
Event Change Question pikapika13[_12_] Excel Programming 5 July 5th 06 07:01 PM
Worksheet_Activate event question Barb Reinhardt Excel Programming 0 June 19th 06 06:32 PM
Event question Fredrik Wahlgren Excel Programming 0 February 9th 05 10:15 PM
Question about an event Joost Excel Programming 2 January 12th 04 01:42 PM
Event Question bwilcox Excel Programming 1 July 21st 03 02:37 PM


All times are GMT +1. The time now is 07:08 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"