transfer complete rows to new sheet

slochin

Board Regular
Joined
Dec 1, 2015
Messages
70
Hello,
I am hoping someone can assist meplease with my project.
I have two sheets with info incolumns .
In sheet one the info spreads fromA-N. In col S and T “yes” is placed if certain criteria is met.
In sheet two info spreads from A-Q.In col R if certain criteria is met a “yes” is inserted.
What I would like to do is to beable to transfer the complete row if “yes” is in the columns asabove and place them in a new sheet.
 
Hello mumps,
Thank you.This code transfers the selected rows from Sheet1 correctly,however does not transfer the selections from Sheet2.No error message.
 
Upvote 0

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
In sheet2 does the formula in col R return Yes, yes, or YES?
 
Upvote 0
The macro is expecting to find the word "Yes" ( case sensitive) so if your formula is returning something like "YES" or "yes" then it won't find it. If that is the case, try:
Code:
Option Compare Text
Sub CopyRows()
    Application.ScreenUpdating = False
    Dim LastRow As Long
    LastRow = Sheets("Sheet1").Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
    Dim rng As Range
    Sheets("Sheet3").UsedRange.ClearContents
    For Each rng In Sheets("Sheet1").Range("S2:S" & LastRow)
        If rng = "Yes" Or rng.Offset(0, 1) = "Yes" Then
            rng.EntireRow.Copy Sheets("Sheet3").Cells(Rows.Count, "A").End(xlUp).Offset(1, 0)
        End If
    Next rng
    LastRow = Sheets("Sheet2").Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
    For Each rng In Sheets("Sheet2").Range("R2:R" & LastRow)
        If rng = "Yes" Then
            rng.EntireRow.Copy Sheets("Sheet3").Cells(Rows.Count, "A").End(xlUp).Offset(1, 0)
        End If
    Next rng
    Application.ScreenUpdating = True
End Sub
 
Upvote 0
Another option would be to convert the rng value to lower case & then compare
Code:
If LCase(Rng.Value) = "yes" Then
 
Upvote 0
Hello mumps,
First of allmy apologies. It appears I have been careless when creating a newsheet and somehow placed the formulas for sheet 2 in the wrongcolumn. Having corrected this ,the formula works of course asexpected.
Once again many thanks for spendingyour time to assist me and providing me with exactly what I had hopedfor.
Thanks also to Fluff for assisting
 
Upvote 0

Forum statistics

Threads
1,214,983
Messages
6,122,583
Members
449,089
Latest member
Motoracer88

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top