View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
david shapiro david shapiro is offline
external usenet poster
 
Posts: 23
Default urgent - changing a range

Thanks to Tom, Norman and others for the suggestions on the code. For
some reason, this part - changing the range on the advanced filter still
doesn`t work:

I`m new to this, how could the following code be adjusted so that:
"criteria file" - the criteria for the advanced filter

"source data" - the large dataset from which to extract

A new worksheet called "final data" is created, and the results of the
advanced filter are put there. (Please do not overwrite/change contents
of "criteria file").

The range on both the "criteria file" and "source data" should be the
whole dataset in the worksheet. Norman, I`m not quite sure what you
mean by criteria column (H). In this case, all of the columns in the
"criteria file" are criteria, so how could this whole range be put?
Would appreciate your suggestions.

Thanks. - David

Sub extractall()
Dim rngData As Range, RngCrit As Range
Dim rngOutput As Range

With ActiveWorkbook
With .Sheets("source data")
Set rngData = .Range("A1").CurrentRegion '
End With

With .Sheets("criteria file")
Set RngCrit = .Range("A1").CurrentRegion '
Set rngOutput = .Range("A1")
End With

.Sheets("criteria file").Activate
rngOutput.CurrentRegion.ClearContents
rngData.AdvancedFilter Action:=xlFilterCopy, _
CriteriaRange:=RngCrit, _
CopyToRange:=rngOutput, _
Unique:=True
End With

End Sub



*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!