hi,
I have a large amount of data (168035 * 374) which i want to process. My task is to search some specific record on user input.
e.g., If user is asked to input some number. Then this number will be matched with all A1 (168035 rows)and if the match occurs in multiple places, it should fetch those records (rows) and save it to another worksheet.
I have some code, which is not efficient. when i run the query, excel becomes non responsive (halts). Please give me some suggestion
NOTE: i am using excel-2007
Here is my code:
I have a large amount of data (168035 * 374) which i want to process. My task is to search some specific record on user input.
e.g., If user is asked to input some number. Then this number will be matched with all A1 (168035 rows)and if the match occurs in multiple places, it should fetch those records (rows) and save it to another worksheet.
I have some code, which is not efficient. when i run the query, excel becomes non responsive (halts). Please give me some suggestion
NOTE: i am using excel-2007
Here is my code:
Code:
Sub copying()
Dim i As long, j As long
Dim strsearch As String, lastline As long, tocopy As long
strsearch = CStr(InputBox("Please Enter the video ID: "))
lastline = Range("A1048576").End(xlUp).Row
j = 1
For i = 1 To lastline
For Each c In Range("A" & 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
MsgBox "All matching data has been copied."
End Sub