![]() |
#1
|
|||
|
|||
![]() Hi Again, Currently trying to setup some code for when I enter a customer name the code looks for an existing name in the list and copies 2 ranges of cells from the same row, and pastes them into the new row being created. below code does find the value and returns the row number for the copy selection, I originally had it do a copy of both ranges together but when pasting that it crashed excel, so I separated them in to 2 copy and paste operations. the code crashes on the second line or pastes the data starting at Column M, is it something to do with Worksheet_SelectionChange? Any guide in the right direction would help out thanks. Code:
Private Sub Worksheet_Change(ByVal Target As Range) Dim Old_Value Old_Value = Target.Value With Sheets("Customer").Range("H4:H5000") Set C = .Find(Old_Value, LookIn:=xlValues) If Not C Is Nothing Then t = C.Row Sheets("Customer").Range("I" & t & ":L" & t).Copy ActiveSheet.Paste Sheets("Customer").Range("Y" & t & ":AH" & t).Copy ActiveSheet.Paste End If End With End Sub |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
kevinbradley57 | Excel Programming | 11 | 07-25-2018 01:51 PM |
Looking to copy select cells in table using dropdown list to paste to new table in another worksheet | CaptainRetired | Excel Programming | 18 | 01-04-2018 07:22 PM |
![]() |
A_Lau | Drawing and Graphics | 3 | 12-19-2014 06:57 AM |
Can you copy & paste cells across worksheets and preserve reference to worksheet? | New Daddy | Excel | 2 | 11-27-2013 07:19 AM |
![]() |
tinfanide | Word | 6 | 03-06-2013 12:21 AM |