I have a column of data where I have to extract the unique values and display them in another column. I'm using this method to do it.
PHP Code:
Sub Find()
Worksheets("readtxt2").Activate
On Error Resume Next
If Range("A1").Value = "" Then
'// handle the error here and End
MsgBox "Could NOT exercute"
End
End If
'the range where it gets values n pastes it here
FindUniqueValues Range("D2 : D3000"), Worksheets("readtxt2").Range("H1")
On Error GoTo 0
End Sub
Sub FindUniqueValues(SourceRange As Range, TargetCell As Range)
SourceRange.AdvancedFilter Action:=xlFilterCopy, _
CopyToRange:=TargetCell, Unique:=True
However, when I run my program and get the unique values, I always get the first two rows of data of the same value(meaning range("A1") and ("A2") shows the same value) How to solve it? Pls help.Thankyou.
??
The code you showed does nothing to the Cells A1 nor A2!
It looks thru the cells in D23000, find all unique values and prints them in Column H!!
The only thing that is don e with anything in A is checking wether A1 is empty, if that'S true, nothing is done!
You're welcome to rate this post!
If your problem is solved, please use the Mark thread as resolved button Wait, I'm too old to hurry!
Yes..thats exactly what is happening.... My ques is, when the data is extracted to column H, the first 2 rows("H1")n ("H2") has the same values... I want to solve that..Sorry, I forgot to quote that the above A1 and A2 wre just examples I was giving...
I tried to code, using BOGUS entries in Column D.The result was as desired!
Maybe the values in your first two rows are not really the same, "B01" is not the same as "B01 "!!! (Check for Spaces!)
You're welcome to rate this post!
If your problem is solved, please use the Mark thread as resolved button Wait, I'm too old to hurry!
No..OPus.. Theyare exactly the same...There's no space whatsoever..I've checked it alreday thoroughly.. How can all the different files generated from the engine coz the same same mistake..? I wonder Pls help....mayb is there anyway to check and filter unique values again?...I don't know
The first value in the Range is never used, it is only displayed as a title.
Look at the name of the Cell H1, its not H1 anymore it's called something like "destinationrange" (dependent on your languagesetting, mine is German, so I don'T have the correct one on hand)
I'm out of here now!
You're welcome to rate this post!
If your problem is solved, please use the Mark thread as resolved button Wait, I'm too old to hurry!
No..what I meant was, it was my mistake for not being observant enough like u..U were the one to enlighten me bout the problem on Range("H1")..its only after that I was able to do.. Thanks alot.