Copy/Paste

DeCaelo

New Member
Joined
Mar 17, 2011
Messages
29
I have 2 columns of data in Sheet 1.

In A is some simple text data.
In B is either "OK" or "NOT OK".

I'm guessing it's a sort of macro I need, where if, say B5 in Sheet1 is "NOT OK", then A5 is copied and posted into A1 of Sheet2 and a 1 put into B1 of Sheet2.

I'm just not entirely sure how to proceed.
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes

Tuelor

Board Regular
Joined
Mar 19, 2011
Messages
101
I would apply an advanced filter, and record a macro doing it if you need to automte it.

D
 

Dryver14

Well-known Member
Joined
Mar 22, 2010
Messages
2,396
This assumes a header in row 1 on sheet2 and you are on sheet1

Code:
Sub MoveOver()
'Kevin Wilson
'23/03/11
Dim NextRow As Long
Dim FinalRow As Long
Dim i As Long
FinalRow = Cells(Rows.Count, 2).End(xlUp).Row
NextRow = Sheet2.Cells(Rows.Count, 1).End(xlUp).Row + 1
Sheet1.Cells(1, 2).Select
For i = 1 To FinalRow
    If Cells(i, 2).Value = "NOT OK" Then
        Sheet2.Cells(NextRow, 1).Value = Sheet1.Cells(i, 1)
        Sheet2.Cells(NextRow, 2).Value = 1
        NextRow = NextRow + 1
    End If
Next i
End Sub
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,167,653
Messages
5,854,963
Members
431,689
Latest member
jacker01

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
Top