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

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
I would apply an advanced filter, and record a macro doing it if you need to automte it.

D
 
Upvote 0
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
 
Upvote 0

Forum statistics

Threads
1,214,649
Messages
6,120,732
Members
448,987
Latest member
marion_davis

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