Thread: event fire
View Single Post
  #19   Report Post  
Posted to microsoft.public.excel.programming
kounoike[_2_] kounoike[_2_] is offline
external usenet poster
 
Posts: 126
Default event fire

I'm not quite sure that i'm following you, i rewrite your code like this.

Public Sub CopyStuff(ByVal target As Range)
Dim wksSummary As Worksheet
Dim rngPaste As Range
Set wksSummary = Sheets("Donors")
Set rngPaste = wksSummary.Cells(65536, "A").End(xlUp).Offset(1, 0)
If target.Font.ColorIndex < 3 Then
target.Font.ColorIndex = 3
Else
Exit Sub
End If
Application.EnableEvents = False
Set rngPaste = rngPaste.Resize(1, 10)
Set target = Range(target.Offset(0, -7), target.Offset(0, 2))
rngPaste.Value = target.Value
rngPaste.Cells(1, 8) = rngPaste.Cells(1, 8) - 10
Application.EnableEvents = True
End Sub

keizi

"Curt" wrote in message
...
event works with minor problem here is code as I changed it. Problem is I
copy one column more than I want on paste. Also it skips a line when
pasting.
Any ideas. I've went in and changed all I can think of. Trigger has been
moved to column (L) Also is there a way to prevent reentering same data or
changing on first worksheet. If you chg trigger data it will reenter the
line. Can this be locked so if user changes the trigger data it will
change
only that entry on Donors sheet Not add a new line. Or maybe I should use
a
different approach to solve this. This is a first go around for this guy
at
something this complex.
Appreciate Greatly your assistance. So will those who use this.
Thanks Again
Public Sub CopyStuff(ByVal target As Range)
Dim wksSummary As Worksheet
Dim rngPaste As Range
Set wksSummary = Sheets("Donors")
Set rngPaste = wksSummary.Cells(65536,€ťA€ť).End(xlUp.Offset(1, 0)
Application.EnableEvents = False
Set rngPaste = rngPaste.Offset(1, 0)
rngPaste = Range(target.Offset(0, -7), target.Offset(0,2))
Range(target.Offset(0, -7), target.Offset(0, 2)).Copy _
Destination:=rngPaste
rngPaste.Offset(0, 7) = target - 10
Application.EnableEvents = True
End Sub





"Carl Hartness" wrote:

The event handler fires three times, first for the change that starts
the process on the sheet with the target, the second and third times
when copied data changes the Donors sheet. Setting EnableEvents to
False before and to True after the copy/paste steps blocks that
behavior. The alternative is to put the SheetChange code only in the
class modules of the sheets where it is wanted, such as Motorcycle,
Indian, etc

Carl.

On Mar 1, 6:27 pm, "kounoike" wrote:
It works for me without error, so I have no idea about it. but my code
fires
event three times in series, it's not good , so my guess is that target
is
supposed to be a single cell but somewhere target has changed to be
cells
and has failed to get target.value. if you show me the code you tried,
then
i'll try to check it.

keizi

"Curt" wrote in message

...



for some reason I am getting type mismatch on this line? runtime
error'13'
If.Column = 10 And target.Value 10 Then
any Ideas
Thanks

"kounoike" wrote:

I modified your code a little and I don't know this is what you
want, but
try this.- Hide quoted text -

- Show quoted text -