Hi all,
I've been trying to wrack my brain around trying to sort this code out. At the minute, the macro runs fine but it's based on a set range between B2:B15000 which is a lot! However, I wanted to make sure that the macro would cover everything.
I was wondering if there was a way to make it choose only the data that is there on the worksheet so that whether it be 1000 rows or 10, it would only work as much as needed?
The current code I have is show below..
Any help would be greatly appreciated!
Thanks all.
MW
I've been trying to wrack my brain around trying to sort this code out. At the minute, the macro runs fine but it's based on a set range between B2:B15000 which is a lot! However, I wanted to make sure that the macro would cover everything.
I was wondering if there was a way to make it choose only the data that is there on the worksheet so that whether it be 1000 rows or 10, it would only work as much as needed?
The current code I have is show below..
Code:
Sub Filter()
'
' Filter Macro
'
'
Sheets("Paste Here").Select
Columns("B:B").Select
Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
Range("B1").Select
ActiveCell.FormulaR1C1 = "Count"
Range("B2").Select
ActiveCell.FormulaR1C1 = "=COUNTIF(C[-1],RC[-1])"
Range("B2").Select
Selection.AutoFill Destination:=Range("B2:B15000")
Range("B2:B15000").Select
ActiveWindow.ScrollRow = 1
Range("A2").Select
ActiveWorkbook.Worksheets("Paste Here").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Paste Here").Sort.SortFields.Add Key:=Range("A2") _
, SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("Paste Here").Sort
.SetRange Range("A2:B15000")
.Header = xlNo
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Rows("1:1").Select
Selection.AutoFilter
Range("B2").Select
End Sub
Any help would be greatly appreciated!
Thanks all.
MW