autofilter

Autofilter using variable Criteria VBA

若如初见. 提交于 2019-12-19 11:24:35
问题 I am trying to put an autofilter on a worksheet using a variable, but it is not working. Dim Criteria As Object i = 1 Set Criteria = ActiveSheet.Cells(i, 1) MsgBox (Criteria.Value) ' this returns BC01.03 However, when I try to filter "Criteria.Value" is not returning anything. Selection.AutoFilter ActiveSheet.Range("$A$1:$BM$204").AutoFilter Field:=2, Criteria1:=" & Criteria.Value & " Please advice. 回答1: Get rid of the quote marks around your Criteria1 argument: ActiveSheet.Range("$A$1:$BM

excel VBA - return Criteria1 Array from an Autofilter

不想你离开。 提交于 2019-12-18 13:42:14
问题 I have a table that I need to return all of the toggled values. When i record a macro after selecting which ones i want it looks like this ActiveSheet.Range("$A$1:$P$1000").AutoFilter Field:=6, Criteria1:=Array("A" _ , "B", "C", "D", "E", "G"), Operator:=xlFilterValues the problem i have is that the a,b,c, etc values that will be filtered by the user will always be changing so I can't hardcode any criteria that way. is there a way i can return an array of what is toggled on in a fashion

Get Last Row From Filtered Range

ⅰ亾dé卋堺 提交于 2019-12-18 08:28:33
问题 How do you find the last row of data when the data in your worksheet is filtered? I have been playing around with Special Cells and Visible Cells but cannot find a solution. I think it must be some kind of variation on what I have below: ... With ws LR = .Range("A" & Rows.Count).End(xlUp).Row .Range("A1:E" & LR).AutoFilter Field:=2, Criteria1:="=4" LRfilt = .Range("A" & Rows.SpecialCells(xlCellTypeVisible).Count).End(xlUp).Row Debug.Print LR Debug.Print LRfilt End With ... File can be found

Excel VBA - Splitting data into report table

邮差的信 提交于 2019-12-18 07:09:28
问题 I'm after a bit of help automating a report for work. I have a spreadsheet with a data dump on, as per screenshot below (this is some data I have mocked up for this example). This spreadsheet also has two other worksheets, one has a list of sales reps, the other has the basic template I need to achieve. The data shows potential new business for our sales reps. This data is split down by sales rep, as well as a rating for the new business (hot, warm, lukewarm, general). The template splits

Filter using array and xlFilterValues

时光总嘲笑我的痴心妄想 提交于 2019-12-17 22:03:38
问题 I have written a code which defines an array and then uses that array as criteria to filter a range. Here's the extract of the code. Somehow it filters out everything and does not display the filtered values. Dim N As Long Sheets("Calculations").Select With Sheets("Calculations") N = .Cells(Rows.Count, "A").End(xlUp).Row ReDim ary(1 To N) For i = 1 To N ary(i) = .Cells(i, 1) Next i End With Sheets("Data").Select Range(Range("A1"), Range("A1").End(xlToRight)).Select Range(Selection, Selection

Trouble filtering out rows on one worksheet based on an array with values from another worksheet in VBA

故事扮演 提交于 2019-12-17 17:02:36
问题 My intention was to have the following code compile data from my "Low CPM 1" worksheet into an array and then filter my active worksheet based on this array. While the macro does seem to affect the filters, none of the values get filtered out. Any help on this matter would be greatly appreciated Sub Macro1() Dim CPM1Array(0 To 300) As Variant For i = 2 To UBound(CPM1Array) CPM1Array(i) = Sheets("Low CPM 1").Cells(i, 2).Value Next i ActiveSheet.Range("$A$1:$H$251").AutoFilter Field:=3,

Trouble filtering out rows on one worksheet based on an array with values from another worksheet in VBA

坚强是说给别人听的谎言 提交于 2019-12-17 17:02:35
问题 My intention was to have the following code compile data from my "Low CPM 1" worksheet into an array and then filter my active worksheet based on this array. While the macro does seem to affect the filters, none of the values get filtered out. Any help on this matter would be greatly appreciated Sub Macro1() Dim CPM1Array(0 To 300) As Variant For i = 2 To UBound(CPM1Array) CPM1Array(i) = Sheets("Low CPM 1").Cells(i, 2).Value Next i ActiveSheet.Range("$A$1:$H$251").AutoFilter Field:=3,

Excel VBA autofilter all but three

随声附和 提交于 2019-12-17 03:22:52
问题 In the continuing saga of my data analysis (First Question), I want to delete all the rows whose departments (Field 7) are not 101, 102 or 103 (the names have been changed to protect the innocent). There are about a hundred departments in the data, so using Criteria1:=Array("104", "105", "106", etc is impractical. I would like to do something like this: myrange.AutoFilter Field:=7, Criteria1:="<>101", Operator:=xlOr, _ Criteria2:="<>102", Operator:=xlOr, Criteria3:="<>103" but Excel doesn't

Excel VBA autofilter all but three

给你一囗甜甜゛ 提交于 2019-12-17 03:22:04
问题 In the continuing saga of my data analysis (First Question), I want to delete all the rows whose departments (Field 7) are not 101, 102 or 103 (the names have been changed to protect the innocent). There are about a hundred departments in the data, so using Criteria1:=Array("104", "105", "106", etc is impractical. I would like to do something like this: myrange.AutoFilter Field:=7, Criteria1:="<>101", Operator:=xlOr, _ Criteria2:="<>102", Operator:=xlOr, Criteria3:="<>103" but Excel doesn't

Set Auto Filtering multiple wildcards

浪子不回头ぞ 提交于 2019-12-17 03:19:05
问题 Right now I am doing coding to set a filter for a data chart. Basically, I don't know how to post the data sheet up here so just try to type them ): (starting from the left is column A) Name * BDevice * Quantity * Sale* Owner Basically I need to filter out for 2 column: -The BDevice with any word contain "M1454" or "M1467" or "M1879" (It means that M1454A or M1467TR would still fit in) -The Owner with PROD or RISK Here is the code I wrote: Sub AutoFilter() ActiveWorkbook.ActiveSheet..Range(B