copy data to other sheet based on conditions

I have this excel sheet which I'm attaching. In the first column I have some numbers and the 2nd column I have a yes/no value where yes is indicated by a value of '1'. I wish to copy the values from the 1st column when the row of the 2nd column equals '1'. How do I do this? I guess with some vb script?

Can someone give me some code in vb because I'd like to learn it too?

If there is an easier way as well can you please show it to me?

Thank you,
Victor copy-data-to-other-sheet.xls
Victor KimuraSEO, Web DeveloperAsked:
Who is Participating?

Try this

Sub kTest()
Dim k(), ka, i As Long, n As Long
ka = [a1].CurrentRegion.Resize(, 2)
ReDim k(1 To UBound(ka, 1), 1 To UBound(ka, 2))
For i = 2 To UBound(ka, 1)
    If ka(i, 2) = 1 Then
        n = n + 1
        k(n, 1) = ka(i, 1): k(n, 2) = ka(i, 2)
    End If
Sheets("Sheet2").Range("a1").Resize(n, 2).Value2 = k
End Sub

Open in new window

Where do you want to copy the values TO?
Victor KimuraSEO, Web DeveloperAuthor Commented:
Thank you. Works nice.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.