PC Review


Reply
Thread Tools Rate Thread

Advanced Filter - Get the unique rows

 
 
Kurt Biesemans
Guest
Posts: n/a
 
      1st Nov 2008
Hello,

I have a worksheet (500 rows) with columns A till E
The values in column E look like this:

Antwerpen
Brussels
Antwerpen
Antwerpen
Mechelen
Antwerpen
Mechelen
Gent

Now with an advance filter I want to get the unique values in column E.
This filter looks like:
lastRow = MyWorksheet.range("A" & rows.count).end(xlup).row
MyWorksheet.Range("E2:E" & lastrow +1).Advancedfilter
Action:xlFilterInplace, Unique:=true

This give me a perfect list of the unique values in column E.
NOW!!! I need to loop over the unique values and put the values somewhere in
another worksheet.

Anybody any idea how I can select the rows and loop over them?

Regards
Kurt


 
Reply With Quote
 
 
 
 
Dave Peterson
Guest
Posts: n/a
 
      1st Nov 2008
If you just need to just move the unique list, you could have the advanced
filter do the work for you.

Dim LastRow As Long
Dim DestCell As Range
Dim myWorkSheet As Worksheet

Set myWorkSheet = Worksheets("sheet2")

Set DestCell = Worksheets.Add.Range("a1") 'A1 of a new worksheet.

With myWorkSheet
LastRow = .Range("A" & .Rows.Count).End(xlUp).Row
myWorkSheet.Range("E2:E" & LastRow).AdvancedFilter _
Action:=xlFilterCopy, copytorange:=DestCell, unique:=True
End With

My data has a header in E2 and I removed the +1 to the lastrow. I didn't
understand why you had it there.

You can change the destcell to any cell in any worksheet you want.

If you don't want the header, then delete it (shift up) after you've done the
advanced filter.





Kurt Biesemans wrote:
>
> Hello,
>
> I have a worksheet (500 rows) with columns A till E
> The values in column E look like this:
>
> Antwerpen
> Brussels
> Antwerpen
> Antwerpen
> Mechelen
> Antwerpen
> Mechelen
> Gent
>
> Now with an advance filter I want to get the unique values in column E.
> This filter looks like:
> lastRow = MyWorksheet.range("A" & rows.count).end(xlup).row
> MyWorksheet.Range("E2:E" & lastrow +1).Advancedfilter
> Action:xlFilterInplace, Unique:=true
>
> This give me a perfect list of the unique values in column E.
> NOW!!! I need to loop over the unique values and put the values somewhere in
> another worksheet.
>
> Anybody any idea how I can select the rows and loop over them?
>
> Regards
> Kurt
>


--

Dave Peterson
 
Reply With Quote
 
ShaneDevenshire
Guest
Posts: n/a
 
      3rd Nov 2008
Hi,

When Excel copies from a filtered set of data it only picks up the visible
cells, so if you want to copy the whole list to a specific location, you can
do somenthing like this

Range("E1", [E1].End(xlDown)).Copy
Sheets("Sheet2").Range("A1").PasteSpecial

--
Thanks,
Shane Devenshire


"Kurt Biesemans" wrote:

> Hello,
>
> I have a worksheet (500 rows) with columns A till E
> The values in column E look like this:
>
> Antwerpen
> Brussels
> Antwerpen
> Antwerpen
> Mechelen
> Antwerpen
> Mechelen
> Gent
>
> Now with an advance filter I want to get the unique values in column E.
> This filter looks like:
> lastRow = MyWorksheet.range("A" & rows.count).end(xlup).row
> MyWorksheet.Range("E2:E" & lastrow +1).Advancedfilter
> Action:xlFilterInplace, Unique:=true
>
> This give me a perfect list of the unique values in column E.
> NOW!!! I need to loop over the unique values and put the values somewhere in
> another worksheet.
>
> Anybody any idea how I can select the rows and loop over them?
>
> Regards
> Kurt
>
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
unique records by advanced filter Stefi Microsoft Excel Misc 10 5th Oct 2009 08:04 AM
Unique Filter Code / Advanced Filter Fester Microsoft Excel Programming 1 30th Oct 2008 05:37 PM
Unique Filter Code / Advanced Filter Fester Microsoft Excel Discussion 1 30th Oct 2008 05:37 PM
Advanced Filter Unique Records and Hidden Rows Kigol Microsoft Excel Programming 1 29th May 2007 07:49 PM
Advanced Filter - Unique Values =?Utf-8?B?RXN0aGVySg==?= Microsoft Excel Programming 4 22nd Aug 2005 01:33 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:22 AM.