LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,452
Default Filter unique in range, only keep visible

Trying to make some code that filters the unique rows in a range, but only
leaves the visible row, making it just as a normal range. So, no blue row
numbers and continuous row numbering without gaps.
Something like this will do it, but I think there must be a shorter more
elegant way:

Sub test()
FilterUniqueInRange ActiveSheet, ActiveWindow.RangeSelection
End Sub


Sub FilterUniqueInRange(sh As Worksheet, rng As Range)

Dim arr
Dim shTemp

sh.Activate
rng.AdvancedFilter Action:=xlFilterInPlace, Unique:=True
ActiveWindow.RangeSelection.Copy

Set shTemp =
ActiveWorkbook.Sheets.Add(after:=Worksheets(Worksh eets.Count))
shTemp.Name = "tempPaste"
shTemp.Activate
ActiveSheet.Paste
Application.CutCopyMode = False

With sh
.ShowAllData
.Cells.Clear
End With

ActiveWindow.RangeSelection.Copy

sh.Activate
Cells(1).Select
ActiveSheet.Paste
Application.CutCopyMode = False

Application.DisplayAlerts = False
shTemp.Delete
Application.DisplayAlerts = True

End Sub


RBS


 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Copy only visible cells after filter is applied/ sum after filter MAM Excel Worksheet Functions 0 April 9th 08 04:09 AM
Sumif for Visible range when using filter anshu[_2_] Excel Discussion (Misc queries) 4 July 20th 07 08:15 AM
unique filter results in some non-unique records. Serials Librarian Excel Discussion (Misc queries) 2 May 26th 06 09:58 PM
Sum Unique Values Across SpecialCellType Visible Range. Mark Excel Programming 1 September 15th 05 03:20 PM
Count unique visible records doktorp Excel Programming 4 December 16th 03 10:25 AM


All times are GMT +1. The time now is 08:09 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"