autofilter

Copy a Filtered Table

喜欢而已 提交于 2020-01-05 06:56:26
问题 Trying to copy a filtered table and paste the results to the bottom of another table. With RollupWeekSheet sh1Col = .Range("Table1").Cells(1).Column LastRollupWeekRow = .Cells(.Rows.Count, sh1Col).End(xlUp).Row End With Dim ComboWeekTable As ListObject Set ComboWeekTable = ComboWeekSheet.ListObjects("Table1") Dim RollupTimeStamp As Date RollupTimeStamp = RollupWeekSheet.Range("B3").Value With ComboWeekTable .Range.AutoFilter Field:=16, Criteria1:=">" & RollupTimeStamp .DataBodyRange.Copy End

Copy a Filtered Table

心已入冬 提交于 2020-01-05 06:54:06
问题 Trying to copy a filtered table and paste the results to the bottom of another table. With RollupWeekSheet sh1Col = .Range("Table1").Cells(1).Column LastRollupWeekRow = .Cells(.Rows.Count, sh1Col).End(xlUp).Row End With Dim ComboWeekTable As ListObject Set ComboWeekTable = ComboWeekSheet.ListObjects("Table1") Dim RollupTimeStamp As Date RollupTimeStamp = RollupWeekSheet.Range("B3").Value With ComboWeekTable .Range.AutoFilter Field:=16, Criteria1:=">" & RollupTimeStamp .DataBodyRange.Copy End

Get all list of possible filter criteria

让人想犯罪 __ 提交于 2020-01-03 05:53:24
问题 From VBA I need to know the list of all criteria that I can choose in filtering columns. For example the following list: [1-ALFA;2-BETA;...5-ETC] 回答1: Say we have data like: and we filter size for large and we want to list the criteria for column A : Sub ShowCriteria() Dim r As Range, c1 As Collection, c2 As Collection Dim msg As String Set c1 = New Collection Set c2 = New Collection Dim LastRow As Integer With Worksheets("sheet1") LastRow = .Range("A" & Worksheets("sheet1").Rows.Count).End

Get all list of possible filter criteria

我的梦境 提交于 2020-01-03 05:53:02
问题 From VBA I need to know the list of all criteria that I can choose in filtering columns. For example the following list: [1-ALFA;2-BETA;...5-ETC] 回答1: Say we have data like: and we filter size for large and we want to list the criteria for column A : Sub ShowCriteria() Dim r As Range, c1 As Collection, c2 As Collection Dim msg As String Set c1 = New Collection Set c2 = New Collection Dim LastRow As Integer With Worksheets("sheet1") LastRow = .Range("A" & Worksheets("sheet1").Rows.Count).End

VBA: Different requirements when coding

你。 提交于 2019-12-25 07:02:31
问题 This is a follow up question from a previous post. So the company I work for has recently updated their Excel from 2003 to 2013. I am now having issues with some pretty basic VBA code. The line Cells.AutoFilter(x, y) in particular is giving me issues. I wrote a very ugly program months ago which looks something like this: ... ActiveSheet.ListObjects("Table1").Range.AutoFilter Field:=11, Criteria1:= _ "0" If wf.CountA(r) > 0 Then ActiveSheet.ListObjects("Table1").Range.AutoFilter Field:=8,

Method 'Range' of object '_Worksheet' failed - Naming range and referring to it in VBA

China☆狼群 提交于 2019-12-25 05:03:28
问题 Within a single macro, I am trying to select a range, name it, and then refer to that range when AutoFiltering data. Here's my code: 'Select and name range Set bDataDump = ActiveWorkbook Set DataDump = bDataDump.Sheets(1) DataDump.Range("A1").Select Range(Selection, Selection.End(xlToRight)).Select Selection.AutoFilter Range(Selection, Selection.End(xlDown)).Select Set myrange = Selection 'AutoFilter that range for everything but PDC1 and delete visible rows 'Code fails on next line DataDump

Excel VSTO - accessing AutoFilter's Array Criteria throws exceptions

孤街浪徒 提交于 2019-12-25 04:34:09
问题 I am working on a C# VSTO project in Excel that needs to save the current AutoFilter information and re-apply the filter after some table update. I have managed to have it work on simple text and number filters. But it fails on Date Filters. On a closer look, it seems when the filter Criteria is an Array, there is no way to access the criteria? Basically, the code myCriteria = someFilter.Criteria2 , which returns a string for simple text filters, throws a COM exception now. The MSDN doc on

Excel macro filter based on multiple cell values

泪湿孤枕 提交于 2019-12-24 01:19:33
问题 I have this simple macro that filters rows based on value in A13 cell. It works fine. With ActiveSheet .Range("B2:F5000").AutoFilter Field:=2, Criteria1:=.Range("A13") End With But I need more values to be applied for this filter, specifically based on two or more cells. So I run this macro: With ActiveSheet .Range("B2:F5000").AutoFilter Field:=2, Criteria1:=.Range("A13:A14:A15") End With But it filters only values based on A15 cell. Why is that? I have read all the topics here, but no

Using an array for autofilter criteria

我的梦境 提交于 2019-12-23 23:10:35
问题 I have the below code which will delete rows based on criteria in column I: Sub Strip() Dim rng As Range With ActiveSheet .Columns("I").AutoFilter Field:=1, Criteria1:="=70-79%", VisibleDropDown:=False Set rng = .AutoFilter.Range End With If rng.Columns("I").SpecialCells(xlCellTypeVisible).Count - 1 > 0 Then Application.DisplayAlerts = False rng.Offset(1, 0).SpecialCells(xlCellTypeVisible).Delete Application.DisplayAlerts = True End If rng.AutoFilter End Sub I have about 100 different

POI Auto Filter

我怕爱的太早我们不能终老 提交于 2019-12-21 03:37:35
问题 How do I use Apache POI to pre-define an auto-filter region in an Excel 2007 document? A small code example or link would be nice. 回答1: Save the first and the last cell from the filter area, and execute: sheet.setAutoFilter(new CellRangeAddress(firstCell.getRow(), lastCell.getRow(), firstCell.getCol(), lastCell.getCol())); For example, from the sheet below. >x (x, y) 0123456 0|--hhh--| h = header 1|--+++--| + = values 2|--+++--| - = empty fields 3|--+++--| 4|-------| fist cell will be the