Click here to Skip to main content
16,016,736 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,
I have some records which needs to be searched in column A of an excel and if those are present in column A then the whole row needs to be copied to sheet2 of excel. So far I have tried this . This is for taking one input at a time . But I want to take input multiple values as a range of values. How to do this ..

VB
Dim strsearch As String, lastline As Integer, tocopy As Integer

strsearch = CStr(InputBox("enter the string to search for"))
lastline = Range("A65536").End(xlUp).Row
j = 1

For i = 1 To lastline
    For Each c In Range("A" & i & ":Z" & i)
        If InStr(c.Text, strsearch) Then
            tocopy = 1
        End If
    Next c
    If tocopy = 1 Then
        Rows(i).Copy Destination:=Sheets(2).Rows(j)
        j = j + 1
    End If
tocopy = 0
Next i



how to search for multiples values at a time . please help
Posted
Updated 12-May-14 19:21pm
v2
Comments
vbn.saravanakumar 14-May-14 10:53am    
Hi..

Another possible solutions is to read the Excel data into a data table and apply RowFilter to get all the records that meets the required criteria..

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900