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

have following code working with two problems. (1) copys more columns than I
want only want to copy (E) thru (L) do not want (M) (2) when trigger cell
in data worksheet is changed code inserts a new line. Wud like to only have
code only make change in target cell that was changed. Not start a new entry.

Help is greatly appreciated
Thanks

Public Sub CopyDonors(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)
' disabling events to block extra passes through
' Workbook_SheetChange caused by changing Donors cells
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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default workbook event

A little confused exactly what you want. Where should the paste occure? You
are passing in a target range and you want to copy some cells based on the
location of that range. Where are the coppied cells supposed to be pasted...
As for part 1 of your question give this a whirl...

Public Sub CopyDonors(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)
' disabling events to block extra passes through
' Workbook_SheetChange caused by changing Donors cells
Application.EnableEvents = False
Set rngPaste = rngPaste.Offset(1, 0) 'Why move down again?
rngPaste = Range(target.Offset(0, -7), target.Offset(0, 2)) 'What is
this?
Range(target.Offset(0, -7), target.Offset(0, 1)).Copy _
Destination:=rngPaste 'Change 2 to 1
rngPaste.Offset(0, 7) = target - 10
Application.EnableEvents = True
End Sub

--
HTH...

Jim Thomlinson


"Curt" wrote:

have following code working with two problems. (1) copys more columns than I
want only want to copy (E) thru (L) do not want (M) (2) when trigger cell
in data worksheet is changed code inserts a new line. Wud like to only have
code only make change in target cell that was changed. Not start a new entry.

Help is greatly appreciated
Thanks

Public Sub CopyDonors(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)
' disabling events to block extra passes through
' Workbook_SheetChange caused by changing Donors cells
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

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

With your help all is working fine on this part now. Trying to figure out to
have multiple conditions in row to trigger event. Hope I suceed. Still
learning
Thanks

"Jim Thomlinson" wrote:

A little confused exactly what you want. Where should the paste occure? You
are passing in a target range and you want to copy some cells based on the
location of that range. Where are the coppied cells supposed to be pasted...
As for part 1 of your question give this a whirl...

Public Sub CopyDonors(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)
' disabling events to block extra passes through
' Workbook_SheetChange caused by changing Donors cells
Application.EnableEvents = False
Set rngPaste = rngPaste.Offset(1, 0) 'Why move down again?
rngPaste = Range(target.Offset(0, -7), target.Offset(0, 2)) 'What is
this?
Range(target.Offset(0, -7), target.Offset(0, 1)).Copy _
Destination:=rngPaste 'Change 2 to 1
rngPaste.Offset(0, 7) = target - 10
Application.EnableEvents = True
End Sub

--
HTH...

Jim Thomlinson


"Curt" wrote:

have following code working with two problems. (1) copys more columns than I
want only want to copy (E) thru (L) do not want (M) (2) when trigger cell
in data worksheet is changed code inserts a new line. Wud like to only have
code only make change in target cell that was changed. Not start a new entry.

Help is greatly appreciated
Thanks

Public Sub CopyDonors(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)
' disabling events to block extra passes through
' Workbook_SheetChange caused by changing Donors cells
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

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
Workbook event Curt Excel Programming 1 March 5th 07 04:47 PM
Workbook Event pusky123 Excel Programming 1 February 26th 06 07:12 PM
Workbook open event G Lam Excel Programming 3 November 12th 04 04:38 PM
Workbook Close Event Stefano Condotta Excel Programming 1 June 16th 04 10:44 PM
Workbook Open Event Paul D[_2_] Excel Programming 0 October 17th 03 02:39 AM


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