Private Sub cmdSerachInfoBasedOnCriteriaCopyRowToAnotherSheet_Click()
Dim UsrCriteria As Long 'if criteria is a string edit this accordingly
Dim varCriteriaRowNum As Long
Dim Src As Worksheet
Dim Rpt As Worksheet
Dim CopRng As Range
Set Src = Sheets("Source")
Set Rpt = Sheets("Report")
Src.Select
'''''''''''''''''''''' Pin Point Search begins ''''''''''''''''''''''''''''''''''''''''
Dim rSrchCriteria As Range 'range to check whether Criteria is available
Range("A1").Select 'Col A has Criteria in Src
UsrCriteria = InputBox("Type the Criteria" & vbCrLf & _
"to search :", "Criteria!")
Set rSrchCriteria = Range("A:A").Find(UsrCriteria, , xlValues, xlWhole)
'code below searches Citeria, only in the column specified above as Selected Range.
If rSrchCriteria Is Nothing Then 'if Criteria is 38, & no record is matching, _
then, 38 is not found.
MsgBox "You typed: " & UsrCriteria & "." & vbCrLf & _
"This is not FOUND." & vbCrLf & _
"So, Nothing to copy!"
Exit Sub
Else 'rSrchCriteria Is Nothing 'if Criteria is 38, _
record found may be 388. So, moving pointer to that record.
With rSrchCriteria
.Activate 'Pointer moved to that record.
End With
If Val(rSrchCriteria) <> Val(UsrCriteria) Then 'if User Criteria is 38, _
Srch Criteria found may be 388. So, 38 is not found.
MsgBox "You typed: " & UsrCriteria & "." & vbCrLf & _
"This is not FOUND." & vbCrLf & _
"So, Nothing to copy!"
Exit Sub
ElseIf Val(rSrchCriteria) = Val(UsrCriteria) Then 'if Criteria is 38 and _
record found is 38, then 38 is found.
varCriteriaRowNum = ActiveCell.Row 'Store Row Criteria
End If 'Val(rSrchCriteria) <> Val(UsrCriteria)
End If 'rSrchCriteria Is Nothing
'''''''''''''''''''''' Pin Point Search ends ''''''''''''''''''''''''''''''''''''''''
Rpt.Cells.ClearContents 'Erases all rows in Report Sheet. If you dont want to erase all rows, edit A2 given below.
Set CopRng = Src.Range("A" & Trim(Str(varCriteriaRowNum))).EntireRow
CopRng.Copy Rpt.Range("A2") 'Copies the searched row in Report Sheet 'If you want to paste on a specific row, edit A2.
Rpt.Select
End Sub