Copying data from 1 sheet to another if meets condition

GabeKnight

New Member
Joined
Jul 29, 2011
Messages
7
Hi,
I am using Excel 2003

Essentially we have a spreadsheet in which if column K displays "Yes" I would like the info in column H to be displayed in another sheet which will be used as a summary sheet.
There are around 278 rows and column K can either be a "Yes" or a "No" depending on conditions.

In the new sheet ("Action Plan") I only want the information from the rows with "Yes" displayed, so if there is 3 Yes's, only 3 lines appear, if 5 Yes's, 5 lines appear, etc.

I understand I'll need to use a macro to add new lines to the summary sheet as it searches through the data for "Yes" but am unsure how to do this as I am new to macros.

Any help would be greatly appreciated.
Many thanks

Tim
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
Try like this - change Sheet1 to suit

Rich (BB code):
Sub cpy()
Dim LR As Long, i As Long
With Sheets("Sheet1")
    LR = .Range("K" & Rows.Count).End(xlUp).Row
    For i = 1 To LR
        If .Range("K" & i).Value = "Yes" Then .Rows(i).Copy Destination:=Sheets("Action Plan").Range("A" & Rows.Count).End(xlUp).Offset(1)
    Next i
End With
End Sub
 
Upvote 0
Cheers for the quick response.....

It seems to almost do what I want. You can see the info scrolling through but ends up only displaying the last row.

Is there a way to display all rows that have "Yes"

Thanks
Tim
 
Upvote 0
I just tested to make sure and it copied all rows with Yes in column K.

Where did you put the code. It has to go in a regular module.
 
Upvote 0
Also, is there data in column A? If not what is the leftmost column with data?
 
Upvote 0
The data is in columns B through K, although A is a header so is merged through various rows.
Sorry if that makes it more awkward.
 
Upvote 0
Try this

Rich (BB code):
Sub cpy()
Dim LR As Long, i As Long
With Sheets("Sheet1")
    LR = .Range("K" & Rows.Count).End(xlUp).Row
    For i = 1 To LR
        If .Range("K" & i).Value = "Yes" Then .Rows(i).Copy Destination:=Sheets("Action Plan").Range("B" & Rows.Count).End(xlUp).Offset(1, -1)
    Next i
End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,587
Messages
6,179,734
Members
452,939
Latest member
WCrawford

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