Excel VBA if cell value match get that cell row copy into new sheet.


If cell value match get that cell row copy into new sheet.

Place a Command Button and add following code and in Excel add some value’s as below image.



Sub copy_past()

Dim copyrng As Long

Dim pastrng As Long

Dim i As Long

With Worksheets("copy")

copyrng = .Cells(.Rows.Count, "C").End(xlUp).Row

End With

With Worksheets("past")

pastrng = .Cells(.Rows.Count, "A").End(xlUp).Row

End With

Range("a1:az1").Copy Destination:=Sheets("past").Range("a1:az1")

For i = 1 To copyrng

If Cells(i, 3).Value = Range("d17") Then

Rows(i).Copy Destination:=Sheets("past").Range("A" & pastrng + 1)

pastrng = pastrng + 1

End If

Next

Sheets("past").Activate

End Sub


Note: Above code sheet names(Copy and Past) is the targeted sheet Name in a worksheet, if you want you can change as you want.



Output. After Click The Copy Button Cells that matching values copy and past in the next sheet.




Explanation: Excel Vba that Find Skin in Column "C" and copy whole Rows from (Sheet Name: Copy) the matching Rows and Past into the Next Sheets(Sheet Name: Past).



Do you like this Page..?? Please give your Email And Subscribe for News Letter Below..!! For daily updates.


Excel VBA if cell value match get that cell row copy into new sheet. Excel VBA if cell value match get that cell row copy into new sheet. Reviewed by Unknown on 22:51 Rating: 5

No comments:

Powered by Blogger.