Store Active Autofilter Criteria In Array Or Range

Nov 18, 2008

I want to perform some operations (basically a secondary filter) based on the values which are currently filtered within a single filter column.


are great, but what if there are more than 2???

i.e. I have a column containing values L01 to L20.

My column is filtered on L05, L06 and L07 (or some other combination).

I want to extract the values and L05, L06 and L07 and do what I will with them.

View 9 Replies


Save/Store & Re-use AutoFilter Criteria

Aug 28, 2006

I run some processing which requires that hidden rows be made visible.

Sub unhide
Dim LastRow As String
lr = CONSTStartRow & ":" & xExcelExtras_spd.LastRow(Main_Sheet)
Main_Sheet.Rows(LastRow).Hidden = False
End Sub

is there any way to save and reapply autofilter criteria?

View 2 Replies View Related

Loop And Find Text In Active Cell Then Store To Array

May 5, 2012

I am trying to loop through column A and I want to store in an array where I find "App" within the cell value. I am trying to find "App" but will store the whole cell value in the array. I could not figure out the Find method, so I tried the MID function but am having no luck.

Here is my code:

Sub Arraytest()
Dim arr As Variant, lastrow As Long, i As Long, f As Long, l As Long
f = 0
lastrow = Sheets("Sheet1").Range("A" & Rows.Count).End(xlUp).Row
ReDim arr(1 To 1, 1 To lastrow)

[Code] .....

View 1 Replies View Related

AutoFilter Using Active Cell As Criteria

Apr 29, 2008

My excel file has a column for customer name (there are more columns btw). I have the filter feature on. The customer list is in column F.

I recorded a macro by copying a customer (from the customer column, say from cell F99). Then I click on the filter arrow and select the 'custom' option and in the dialog box that comes up, I paste the copied customer and try to find other records which have the same customer name.

This works great but when I run the macro for some other customer, say from cell F200, the pasting part, pastes the customer that I had selected when recording the macro.

Is there a solution to make this generic so that the macro will work in a manner that I simply highlight the cell of the desired customer and then then run the macro which will give me the result.

View 7 Replies View Related

Store Range Objects In Vba Array

Apr 17, 2008

I can't quite seem to figure out the syntax for pulling a Range variable out of an array of type variant. I always seem to receive the error message "Object variable or With block not set", an example of my code as follows:

Dim currentRange As Range
For i = 2 To UBound(myArray)
currentRange = myArray(i)
' insert code here

I have also tried:

Dim currentRange As Range
For i = 2 To UBound(myArray)
Set currentRange = myArray(i)
' insert code here

Which results in the error "Object required". What is the correct syntax?

View 4 Replies View Related

Store Range Values In Variable Array

Apr 20, 2008

I have a list of names from cell A1:A10 in sheet "Input." Each of these names has its own corresponding sheet in the workbook. I want to be able to run the same exact VBA code for each sheet. In other words, I am trying to get my name variable to automatically change to the next value on sheet "Input." I'm sure this is pretty simple to do, but I can't seem to find anything that works!

View 5 Replies View Related

Autofilter Criteria With Array NOT EQUAL

May 23, 2013

Filter below:


Sheets("Sheet1").Range("$A$3:$AO$64999").AutoFilter Field:=1,
Criteria1:=Array("0" _, "1", "2", "3", ""), Operator:=xlFilterValues

Now I would like to change to exclude these values, tried some tricks, like:

Criteria1:=Array("0" _, "1", "2", "3", ""), Operator:=xlFilterValues

but not working.

View 2 Replies View Related

Using Autofilter And Multiple Criteria - Array Is Not Working Properly

Oct 12, 2012

I thought I had been able to use array to have more than two criterias with Autofilter, but now I am unable to make the following code work. What I am trying to do is have all the records that does not contain either N/A, S/O or xx and also have a filter on column 125 for the value "OUI".

Sub test()
Set ws1 = ThisWorkbook.Sheets("SOMMAIRE_EN_ALL")
Set ws2 = Workbooks("Fichier_central_2013_anglais_2_CLEAN").Sheets("DETAIL_CONCAT")
Set r = ws2.Range("A1:du4783")

[Code] .....

View 3 Replies View Related

Excel 2010 :: Macro With Autofilter With Array To Remove Unwanted Criteria With Wildcard

Apr 28, 2014

I'm having a hard time making this maro work in Excel 2010.

I need it to filter out the items "AR", "BATCH", and the line of "Total:*" where the * is a total amount of any given number dependant on the day.

Below is the coding I have that Excel is not liking.

Sub FilterAccurateRawData()
' FilterAccurateRawData Macro
ActiveSheet.Range("$A$1:$AA$45415").AutoFilter Field:=1, Criteria1:=Array("<>AR", "<>BATCH", "<>Total:*")
End Sub

View 3 Replies View Related

Range Name In Autofilter Criteria

Jun 22, 2007

I'm trying to make the criteria in an autofilter bit of code be the value of a cell in my spreadhseet. I have named the cell and would like to reference the named range rather than the cell address if possible.

Exp = Range("ExpenseGroup")

Selection.AutoFilter Field:=2, Criteria1:=Exp

ExpenseGroup is my range which is located on sheet "cntrl" cell "G5"

When I run my code it referes to line 1 and says" Function call on lefthand side of assignment must return a Varient or Object".

View 8 Replies View Related

Storing Autofilter Criteria In A Range

Sep 17, 2013

I would like to know that is there any way of recording criteria when I filtered data.

For example; A1,A2,A3,A4,A5,A6,A7,A8,A9,A10 and A11

I have this data such as Data,1,2,3,4,5,6,7,8,9,10 (starting from Range A2). Now when I created auto filter as

ActiveSheet.Range("$A$2:$A$11" _
).AutoFilter Field:=1, Criteria1:=Array("2", "3", "4", "5"), Operator:=xlFilterValues

And this criteria can be changed by the user anytime. Now for some reason sometimes I trigger a code which works under Function key(F8) and it refresh some data from the database. Just before it gets the data, it will remove the filter such as :

ActiveSheet.Range("$A$1:$A$11" _
).AutoFilter Field:=1

My problem is after I run my code (under F8), I want to filter back with the same criteria. Is there anyway that i record my criteria in any cell whenever I filter?

View 2 Replies View Related

Using For / Next To Store 3D Array

Jul 30, 2012

I am trying to write a VBA procedure that uses nested For/Next loops to store the contents of a range in three worksheets to a 3 D array and then input the array into another location.

I have no problem doing this for a 2 D array, but am completely stumped on what changes I need to make in order to perform the same task on a 3 D array.

I will post my code for 2 D arrays below and will also post the uncompleted 3 D code, although, it is currently of no use because I am so lost on the 3 D array.

How do I reference sheet1,sheet 2 etc. when declaring my 3 D array? I know how to reference the rows and columns for my 2 D array by using the cells or range object, but what to do for the different sheets.

Two D Array:

Public Sub For_Next_Two_D_Array() Dim I As Integer
Dim J As Integer
Dim MyArray(4, 4) As Integer

For I = 1 To 5
For J = 1 To 5
MyArray(I - 1, J - 1) = Cells(I, J).Value

[Code] ........

Three D array:

Public Sub Store_ThreeD_Array()
Dim I As Integer
Dim J As Integer
Dim S As Integer

[Code] ......

View 6 Replies View Related

Use Array To Store All The Results Of The For Loop

Jun 19, 2008

I would like to use array v to store all the results of the for loop u...How can Ido it?

Dim myRange As Range
Dim AnsRange1 As Integer
Dim AnsRange As Range
Set myRange = Application.InputBox(Prompt:="Select row to insert 10 rows below", Type:=8)
AnsRange1 = myRange.Row
Dim u As Integer
Dim v As Integer
Dim var() As Single
v = 0
For u = 23 To 24022 Step 9
var(v) = u
Next u
If Not (AnsRange1 = v) Then
MsgBox AnsRange1
Range(AnsRange1 & ":" & AnsRange1 + 9).Insert Shift:=xlDown
End If
End If

View 9 Replies View Related

Store Line Of Text Into An Array

Dec 3, 2008

i am not good in programming.In an outlook i am trying to write a maro.

I am reading lines from a text using readLine(), how i can store each line into an array using vbscript. I write the code as follows,

While Not F.AtEndOfStream
s = F.readline
Start = InStr(s, "@")
If (Start > 0) Then
- Here i need an array, when start>0 , store that line into an array

View 9 Replies View Related

Store In Array List Of Numbers Within Same Cell

Mar 8, 2013

I have in column B, cells that have any number, one number or several like B2.



Thinking that I have a loop for rows 1 to 3:

When in column "A" is "No", I want to consider values in C and D to get:


a[1]=Cells(1,"C") & "-" & Cells(1,"D") & "-" & "ABC"

But when in column "A" is "Yes", I want to store in array each value within cell in B (in this example B2) to apply later a For/For Each
over each number (in this example are 3 values only within cell B2), something like:

a[1]=Value_In_B2[1] & "-" & "ABC"
a[2]=Value_In_B2[2] & "-" & "ABC"
a[3]=Value_In_B2[3] & "-" & "ABC"

View 6 Replies View Related

Store Unique Filter Values Into An Array

Jan 21, 2009

In an excel i have 3 columns they it contains around 12000 records

Group FA Title
A S1 bbbb
A M1 xxxx
A M2 eeeee
A S1 ffffff
A S1 pppp
A M3 aaaaa
A M2 ooooo
A M2 qqqq
A M1 ttttt

Here i need to get the unique FA, so i filter the column FA, my question is, After filter with FA column ,is there any way to store these unique FA(ie S1,M1,M2,M3) into an array using vba?

View 9 Replies View Related

Store/Pass Filtered List Values To An Array

Aug 30, 2006

how can i store the values of an autofilter's list in a array using VBA.

View 4 Replies View Related

AutoFilter Non Active Worksheet

Oct 2, 2007

I have a chart that gets updated to show the desired reporting period by clicking a button to run some code which applies filtering to the source worksheet using a value selected from a drop down validation list on the chart worksheet. When the code runs, the source worksheet displays temporarily. How do I prevent this switching back and forth between the data and chart worksheets during code execution? Undoubtedly, there is a better way to code this.

Sub Chart_FilterPPM()
Application.DisplayAlerts = False
wk = Worksheets("Charts"). Range("D63")
Worksheets("Leak Data").Activate
With Worksheets("Leak Data")
.AutoFilterMode = False
End With
With Range("Headings_LeakData").AutoFilter
Selection.AutoFilter Field:=2, Criteria1:=wk
Selection.AutoFilter Field:=11, Criteria1:=">5000", Operator:=xlAnd
End With
Application.DisplayAlerts = False
End Sub

View 3 Replies View Related

Autofilter Active Column Non Blanks?

Mar 25, 2014

I need a VBA code to do the following:

- The active cell i.e. the selected cell can be anywhere on row 11 (this is a merged cell with row 12 but I can unmerge if causes problems)

- The filter needs to be applied to the rows below the active cell (at most this will be about 10,000 rows below)

- I need to filter for non-blanks only

- Above row 11 there is one blank row and a number of filled rows; these need to be ignored i.e. excluded from the filter

- In this case I will need the filter to work on the cell with 'France Trade Product' in it

- The filter would need to hide rows below this cell except for row 16 where a non blank is found


View 1 Replies View Related

AutoFilter Method Of Range Class Failed - Yet Autofilter Works.

Sep 25, 2009

Im sure this is a very common problem. I tried searching for it but I havent found anything that solves this for me. Here is the code Im using:

View 3 Replies View Related

Autofilter Block Of Data From Active Cells Offset

Jul 16, 2012

Thats the best I could describe that What I face today is the means to run a VBA Autofilter from an Activecell. The Activecell is a search result. I have a table that spans from A1 to E5000. The Activecell will always be in Column A. What I need to happen in when the Activecell is found an Autofilter is placed in the block of data from Column B to E. The rows will change after every search hence my dilemma. Each block of data has its own header as well

So if my Activecell is A2 then I need B1:E4 Autofiltered then Column E sorted Smallest value to Largest. The Activecell needs to remain static. The size of the blocks of data are exactly the same.

Here is a photo example of the desired result. Untitled.jpg

There are hundreds of blocks of data like this.

View 7 Replies View Related

Autofilter Macro: Goto The Next Criteria Down Until Certain Criteria Is Reached

Oct 22, 2008

I am trying to make an "intelligent" auto filter that with filter with increasing restriction until a certain criteria is met.

The list runs from A5:G20. In coloumn G is the number of hours associated with each event. And in A1 I have the percentage of items showing/whole list so it I have 15 rows on the list, and I filter so that only 5 are showing, cell a1=33%

How can I make a macro that will autofilter until the the a1=5%
Like having filter criter = equal or greater then 1 hour,
if a1 > 5%
Then criteria + 1 hour
If A1=<5%, then stop.

basically a seed criteria of 1 hour, adding 1 hour until the value in a1 = 5%

View 6 Replies View Related

Array In Autofilter

Oct 1, 2008

When I run the following code, it just returns records that matches "Commonwealth" and not a single record with "State". What am I doing wrong?

View 10 Replies View Related

Export Range To JPG And Store To Server

Oct 30, 2012

I have code which is convert some range of excel to Png and store to my local drive. This code is working fine.

I have created web site on my intranet and the data store on server, now i use this code and pickup image from my local storage i.e. from "C" Drive and paste in to service folder, bcoz i uploaded report as a Image and it timely refreshed and changed

Is there any way so this code directly store to service folder, if i can use IP address or HTTP path

I had tried with HTTP path but it is not working.

My server path is [URL] .......

Is there any way when local folder got image than automatically server folder also get same image...

Sub bah()
''' Set Range you want to export to file
Dim rgExp As Range: Set rgExp = Range("B2:C6")
''' Copy range as picture onto Clipboard
rgExp.CopyPicture Appearance:=xlScreen, format:=xlBitmap
''' Create an empty chart with exact size of range copied

[Code] .........

View 9 Replies View Related

Loop To Store Data From A Range

Jul 17, 2008

I am trying to do is use a loop to store data from a range into a 3 or 4 dimensional Array and then output the data from the Array in another range. so for example the i want loop through the data in this range and store all data that is in account 701 into an array and then output this information in another range (tab). The data would have several different account but I only want to see one at a time.

Account Price Amount 701 150 1,000,000 701 125 250,000,000 701 3.25 6,000,000 702 4.25 25,000,000 702 2.35 3,600,000 702 2.55 10,000,000

View 9 Replies View Related

Store Barcodes In Range Of Cells In Excel?

May 2, 2006

If I want to store bar codes in a range of cells in Excel, how do I format the cell so the barcode appears as scanned in.

We are scanning in Barcode from our inventory to our excel stock book.

I am doing it now but when we export it out or link it to an access table, it either does not appear or is truncated.

View 4 Replies View Related

Excel 2007 :: Autofilter Not Equal VBA With Array

Mar 21, 2013

Selection.AutoFilter Field:=5, Criteria1:=Array("CHF", "DKK", "EUR", "GBP", "NOK", "SEK", "USD")

I am trying to use VBA to filter a list for not equal to. See line above. I want to filter a table I have for unknown Currencies basically.

View 1 Replies View Related

Filter An Array (the Longer One) Using The Shorter Array As The Criteria

Aug 26, 2009

I am trying to filter an array (the longer one) using the shorter array as the criteria. I am currently doing this using the following method

IF(LOOKUP(lookup cell, array)=lookupcell, lookupcell, "FALSE")

I then copy and paste 'values' and filter out the 'false' to get my final result.

This has worked in the past, but for some reason that I simply can't figure out, the formula isnt working! I've attached the example, and I've highlighted a number in blue (cell E522 and C103), (that should be being found in the 'LOOKUP' function) but is returning a "FALSE". I have looked over the code and simply can't figure out why Excel isn't returning the right value.

This is obviously happening for a quite a few of my numbers, as my filter result is returning an array that is about 1500 shorter than it should be. I have highlighted E522 as the 'example cell' to look at.

View 6 Replies View Related

Excel 2010 :: VB Autofilter Using Array To Exclude Items

Jun 6, 2013

I have data that is formatted in an Excel 2010 table. The two columns in question are [Invoice #] and [Description]. In the description column I have descriptions of products as well as freight. The same invoice number would be tied to the product description as well as its associated freight. I need to filter out certain product types and their associated freight items.

The macro I wrote creates an array of invoice numbers that I want to filter out and leave the remaining invoices, but I can't get the filtering part to work. Here is my code:

Dim Invoices() As Variant 'array of invoice numbers
Dim Descriptions() As Variant 'array of Descriptions
Dim InvoiceFilter() As Variant 'array of invoice numbers to filter
Dim i As Integer 'counter
Dim j As Integer
j = 1


What happens now is that it filters out all values in the Invoice column instead of only the values in the InvoiceFilter array.

View 1 Replies View Related

Variables To Contruct The Name Of The Active Array

Jun 24, 2008

I am trying to construct an indirect array reference as follows;

Dim A10 As Variant
Dim A11 As Variant
Dim A12 As Variant
For i = 0 To 2
String1 = "A" & (10 + i)
String1 = Cells(6, D1_CNum + i).Resize(2995, 1)

But the above doesn't work, what would be the correct way of creating a reference to an Array using variables to contruct the name of the active Array?

I was hoping String1 would equal "A10", so that on the Cells command Array A10, A11 and A12 would be filled using the value of String1??

View 9 Replies View Related

Copyrights 2005-15, All rights reserved