I want to copy the selective data (Columns) from one excel sheet to another on a filter of yes and no .
Here is my excel
Now the problem is when i execute the code all the data of a particular column is copied and filter for yes and no is not working as per my code
Here is my code
Sub testIt()
Dim r As Long, endRow As Long
endRow = 20 ' of course it's best to retrieve the last used row number via a function
'pasteRangeIndex = 1
For r = 5 To endRow 'Loop through sheet1 and search for your criteria
If Cells(r, Columns("H").Column).Value = "yes" Then 'Found
'Copy the current cell
Range("G1:G19").Select
Selection.Copy
Sheets("Sheet1").Select
Range("A1:A19").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
Sheets("Sheet3").Select
Range("C1:C19").Select
Selection.Copy
Sheets("Sheet1").Select
Range("B1:B19").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
Sheets("Sheet3").Select
Range("D1:D19").Select
Selection.Copy
Sheets("Sheet1").Select
Range("C1:C19").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
End If
Next r
End Sub
Moderator Note:
Pls use code tags around your code next time as per forum rules.
Bookmarks