VBA Bringing over unique rows if column O contains an N

Stephen_IV

Well-known Member
Joined
Mar 17, 2003
Messages
995
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
What I am trying to do is to bring over all of the data in column O that contains an N if the data in column E is unique. I can bring over all of the data that has an "N" with the code below but I am having trouble bringing over the unique data theat is unique with an N.


In other words if the value in column E is unique and column O contains an N then copy over the entirerow to sheet2.

Thanks in advance Stephen.


Sub pullingdata()
Dim r As Range
Set r = Range("O2:O14204")
For Each cell In r
If cell.Value = "N" Then
cell.EntireRow.Copy Sheets("sheet2").Range("a65536").End(xlUp)(2, 1)
End If
Next
End Sub
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.

hayden

Board Regular
Joined
Sep 23, 2005
Messages
159
Stephen,
While I can't do this all at once in VBA, I think you could filter the data in excel (slecting unique records only) first and then run your script to bring over all those with an "N".

Might work.

Hayden
 

Forum statistics

Threads
1,136,601
Messages
5,676,732
Members
419,648
Latest member
jmuench

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