VBA Copy Unique Values from Column with Blanks

GingerMermaid

New Member
Joined
Nov 2, 2015
Messages
8
Hello Amazing Excel Gurus,

I have been struggling with this one for far too long and I still can't figure out what I'm doing wrong. I will try to be as clear as possible:

My spreadsheet has a list of user numbers in Column I. The length of data varies each month and there are duplicate user numbers listed.
Column M is filled with a "Y" or "N" in each row, indicating whether the user number should be counted or not.
Column N has a formula dragged down to populate it with the user number (minus the last digit) if the user should be counted: =IF(M2="Y",LEFT(I2,LEN(I2)-1),"")
This means that Column N appears to have many blanks, since not all users should be counted, but it also has some duplicates, since some users should be counted more than once.
Example:
I
J
KLM
NO
USER
PST DATE Debit CreditCount User?
Count
Don't
Count
12355/24/2016
D N

123
12355/2/2016 C Y
123
32155/2/2016 C N
321
55555/2/2016 C N555
70955/2/2016 D N709
45655/2/2016 C Y456
1235
5/2/2016 D Y
123

161655/2/2016 C N1616

<tbody>
</tbody>

I am trying to find a way to select all the Counted users and copy the unique ones over to Column P. I have searched for answers and I came up with 2 methods that seemed to make sense to me, but the first is giving me a Runtime Error '1004' and says that it requires at least two rows of data and the second says the extract range has a missing or illegal field name:

TRIAL METHOD 1:
With ActiveSheet

.Range("N1", Range("N1").End(xlUp)).AdvancedFilter _
Action:=xlFilterCopy, _
CopyToRange:=ActiveSheet.Range("P1"), _
Unique:=True
End With

TRIAL METHOD 2:
With ActiveSheet

.Range("N1:N" & Range("N" & Rows.Count).End(xlUp).Row).AdvancedFilter _
Action:=xlFilterCopy, _
CopyToRange:=ActiveSheet.Range("P1"), _
Unique:=True

End With

Any assistance would be much appreciated and thank you in advance for even taking the time to consider my problem! :)
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
userYES_NOcount
1234N
1235N
1236Y123
1237N
1238N
1294Y129
1234N
1235N
1236Y123Count of count
1237NcountTotal
1238N1232
1279Y1271271
1234N1281
1235N1291
1236YGrand Total5
1237N
1238N
1289Y128
a pivot table lists in col 1 only the unique numbers
easy to get total of 4 with a formula
problem statementbut is this what you want ?
count only 123,127,128,129

<colgroup><col span="7"><col><col><col span="5"></colgroup><tbody>
</tbody>
 
Upvote 0

Forum statistics

Threads
1,215,219
Messages
6,123,685
Members
449,117
Latest member
Aaagu

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