How do I add Paste values to this code?

Closed
Jan - 4 Apr 2010 à 20:49
rizvisa1 Posts 4478 Registration date Thursday 28 January 2010 Status Contributor Last seen 5 May 2022 - 5 Apr 2010 à 00:22
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

Related:

1 response

rizvisa1 Posts 4478 Registration date Thursday 28 January 2010 Status Contributor Last seen 5 May 2022 766
5 Apr 2010 à 00:22
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