View Single Post
 
Old 02-18-2016, 10:14 PM
ufopilot ufopilot is offline Windows XP Office 2007
Novice
 
Join Date: Oct 2015
Posts: 6
ufopilot is on a distinguished road
Default 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
Attached Files
File Type: xlsm CPY-PSTE.xlsm (106.2 KB, 10 views)

Last edited by ufopilot; 02-19-2016 at 02:47 AM.
Reply With Quote