#1
|
|||
|
|||
Find criteria, then paste- code is overwriting data
Hi all,
My code is set up to copy a range of data ("B27:B49"), find the corresponding "header"("B97") in row 99 ("B99U99"). Then the copied data will be offset 1 row down from the found header and pasted below it. The user then will go back to create the next header. The problem is that it keeps copying the next set of data in the same column (C), even though the header does not (any longer) match the "rngDetailToSearch.Find(What...." It overwrites the existing data from the last input, and will not move to the next cell in row 99 that actually matches the new header, named in B97. I could use a second set of eyes to see what I am doing wrong. Thank you HTML Code:
Sub PlaceInput() 'ActiveSheet.Unprotect Dim myDetailFind As Integer Dim rngDetail As Range Dim rngDetailToSearch As Range Dim rngDetailFound As Range Set wks = ActiveSheet Set rngDetailToSearch = ActiveSheet.Range("B99:DU99") Set rngDetailFound = rngDetailToSearch.Find(What:=wks.Range("B97"), _ LookIn:=xlValues, LookAt:=xlPart, MatchCase:=False) If Not rngDetailFound Is Nothing Then ActiveSheet.Range("B27:B49").Copy rngDetailFound.Offset(1, 0).PasteSpecial xlValues 'MsgBox myFind & " Input has been logged." Else End If Range("B10").ClearContents Range("B10").Select 'ActiveSheet.Protect End Sub Last edited by ufopilot; 02-19-2016 at 02:47 AM. |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Using Paste in my VBA code | Hdata | Word VBA | 10 | 03-25-2019 07:57 AM |
How to return a value in a data table using vertical and horizontal criteria | oswald | Excel | 1 | 02-08-2015 02:01 AM |
Excel VBA Macro - Deleting Specific Data based on criteria | MD011 | Excel Programming | 3 | 12-10-2014 02:15 AM |
How to paste the data from one table into the cells of another table, without overwriting anything | CClio333 | Word Tables | 1 | 08-12-2014 05:17 PM |
How to count cells containing data and meet certain criteria | AdamNT | Excel | 1 | 08-11-2006 11:51 PM |