bulletshiva
New Member
- Joined
- Jun 6, 2018
- Messages
- 11
Hello,
I have a task to move the rows to sheet 2 based on a search value in a range. The below code will search a particular column and copies all the rows to sheet2.
Now i want to check a range of columns for a value and copy only required columns like Item_id and description to sheet2.
request you to modify the code.
<colgroup><col><col span="2"><col span="6"></colgroup><tbody>
</tbody>
Sub Button1_Click()
a = Worksheets("sheet1").Cells(Row.Count, 1).End(xlUp).Row
For i = 2 To a
If Worksheets("sheet1").Cells(i, 3).Value = "L" Then
Worksheets("sheet1").Row(i).Copy
Worksheets("sheet2").Activate
b = Worksheets("sheet2").Cells(Rows.Count, 1).End(xlUp).Row
Worksheets("sheet2").Cells(b + 1, 1).Select
ActiveSheet.Paste
Worksheets("sheet1").Activate
End If
Next
Application.CutCopyMode = False
ThisWorkbook.Worksheets("sheet1").Cells(1, 1).Select
End Sub
I have a task to move the rows to sheet 2 based on a search value in a range. The below code will search a particular column and copies all the rows to sheet2.
Now i want to check a range of columns for a value and copy only required columns like Item_id and description to sheet2.
request you to modify the code.
Item id | Description | Date | Range | |||||
A002M22002 | pump | 2/8/2018 | K | L | Z | X | Q | S |
A002M22003 | handle | 1/8/2018 | K | M | Z | L | Q | S |
A002M22004 | washer | 5/8/2018 | K | N | Z | X | L | E |
<colgroup><col><col span="2"><col span="6"></colgroup><tbody>
</tbody>
Sub Button1_Click()
a = Worksheets("sheet1").Cells(Row.Count, 1).End(xlUp).Row
For i = 2 To a
If Worksheets("sheet1").Cells(i, 3).Value = "L" Then
Worksheets("sheet1").Row(i).Copy
Worksheets("sheet2").Activate
b = Worksheets("sheet2").Cells(Rows.Count, 1).End(xlUp).Row
Worksheets("sheet2").Cells(b + 1, 1).Select
ActiveSheet.Paste
Worksheets("sheet1").Activate
End If
Next
Application.CutCopyMode = False
ThisWorkbook.Worksheets("sheet1").Cells(1, 1).Select
End Sub