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

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
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,224,594
Messages
6,179,795
Members
452,943
Latest member
Newbie4296

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