How do I add Paste values to this code?

Closed
Jan - Apr 4, 2010 at 08:49 PM
rizvisa1 Posts 4479 Registration date Thursday January 28, 2010 Status Contributor Last seen May 5, 2022 - Apr 5, 2010 at 12:22 AM
How do you add pate values to this code?

Sub customcopy()
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("B" & 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

1 reply

rizvisa1 Posts 4479 Registration date Thursday January 28, 2010 Status Contributor Last seen May 5, 2022 768
Apr 5, 2010 at 12:22 AM
I have not tested it but i think if you change this line

Rows(i).Copy Destination:=Sheets(2).Rows(j)

to

Rows(i).Copy
Sheets(2).Select
Cells(j, "A").Select
ActiveSheet.PasteSpecial xlValues
0