ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Copy/paste rows to new sheet based on cell value (https://www.excelbanter.com/excel-programming/416774-copy-paste-rows-new-sheet-based-cell-value.html)

taylor

Copy/paste rows to new sheet based on cell value
 
I have a large spreadsheet in which one column returns "check status",
"visit", or "Send Letter 2" based on an IF/THEN formula. Is there a way to
automatically select those rows containing "check status", "visit", and "Send
Letter 2", copy the row and paste it onto a new sheet? Do I need a macro for
this?

Dan R.

Copy/paste rows to new sheet based on cell value
 
This assumes your values are in column A:

Sub CopyRows()
lrow = Sheets(1).Cells(Rows.Count, "A").End(xlUp).Row
For i = 1 To lrow
dest = Sheets(2).Cells(Rows.Count, "A").End(xlUp).Row
If Cells(i, 1).Value = "check status" Or _
Cells(i, 1).Value = "visit" Or _
Cells(i, 1).Value = "Send Letter 2" Then
Rows(i).Copy Sheets(2).Rows(dest + 1)
End If
Next i
End Sub

--
Dan


On Sep 9, 12:04*pm, Taylor wrote:
I have a large spreadsheet in which one column returns "check status",
"visit", or "Send Letter 2" based on an IF/THEN formula. *Is there a way to
automatically select those rows containing "check status", "visit", and "Send
Letter 2", copy the row and paste it onto a new sheet? *Do I need a macro for
this?



All times are GMT +1. The time now is 10:10 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com