Advanced filtering of Union of named Ranges

E

El Cuarto Mago

First off, apologies if this has been discussed elsewhere. I've been
looking for two days w/o success. First, I'll describe what I'm trying
to acomplish, what I have done so far and what I came here to get help
on.

I have a large set of data (8 points sampled every 45mS for 10
minutes) collected from a machine and saved as CSV. I'm not sure what
the users of this data are looking to analyze or specifically
concerned about studying. Therefore I made the graph dynamic. Specific
sets (COLUMNS) of this data are being graphed. The Graph is
dynamically plotting Dynamic series achieved by using Names ranges for
start cell and the end cell is an offset from the start cell.
Example Series Source Data:
Name ="MaxCurrentDieTempValue"
Values ='Temp Analysis.xls'!MaxCurrentDieTempValue
where
MaxCurrentDieTempValue
=OFFSET(MaxCurrentDieTempValueStartCell,StartPosition,,Length,)

Name ="DieCounter"
Values ='Temp Analysis.xls'!DieCounter
where
DieCounter=OFFSET(DieCounterStartCell,StartPosition,,Length,)


Start Position and length are controlled by two slider bars. This is
great as it allows the user to essentially pan and zoom in to the
specific area of interest. I also give the user the Max, Min, Diff and
deviation.

HERE'S THE PROBLEM:
I want to create a subset of the above data to report on the
individual dies (DieCounter = 0, Die Counter = 1, etc etc). I
therefore tried to programatically run an advanced filter on the union
of the two ranges to output a range where die counter is equal to some
value. I figured I could then either graph the results and (again) do
the Max, Min, Diff and stddev of the individual and compare it to the
overall.

I CAN'T GET THE FILTER TO WORK. Here's what I have

Sub Macro1()
Dim rngToFilter As Range
Dim rngTargetRange As Range

Worksheets("Graph Sheet").Activate

Set rngToFilter =
Application.Union(Range("MaxCurrentDieTempValue"),
Range("DieCounter"))

rngToFilter.AdvancedFilter _
Action:=xlFilterCopy, _
CriteriaRange:=Worksheets("Graph Sheet").Range("G1:G2"), _
CopyToRange:=Range(rngTargetRange), _
Unique:=False

End Sub

WHERE CELL "G1" of "Graph Sheet" CONTAINS A "0". I should then be able
to create a graph series out of rngTargetRange and get the MIN, MAX,
etc, etc.

This seems like the right approach but I keep getting error 400.

Someone please help me.
 
E

El Cuarto Mago

I'm closer using what was pasted below. However still getting an error
400. I think because the "TestTargetRange" appears to consist of ONLY
one cell even though when pasted into a worksheet (by naming a cell
via drop down window on worksheet) it pastes two columns and over 1300
rows. I'm thinking I'll next try to resize the range using offset or
resize. It sure would be nice if someone more knowledgable than I
would help out.

Dim rngToFilter As Range
Dim rngTargetRange As Range
Dim rngFilterCriteria As Range

Range("M1:M2").Name = "rngFilterCriteria"

Range("rngFilterCriteria").Cells(1).FormulaR1C1 =
"=""gctrDieCount.ACC"""
Range("rngFilterCriteria").Cells(2).FormulaR1C1 = "=""7"""

Union(Range("TestMaxCurrentDieTempValue"),
Range("TestDieCounterValue")).Copy _
Destination:=Range("TestTargetRange")

Range("TestTargetRange").AdvancedFilter Action:=xlFilterInPlace,
CriteriaRange:= _ ' this is where it breaks. - error 400. that error
400 is so lame.
Range("rngFilterCriteria")
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top