Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Macro : seeking max value after an Autofilter

Dear Experts

My excel sheet encloses 2 columns
- 1st column is a zip code with Data/Filter/Autofilter on
- 2nd column is a numbe
In a macro :
- I filter data of the1st colum using the autofilter (i.e. Selection.AutoFilter Field:=1, Criteria1:="10080"
- I want then to get the max of the resulting numbers in the 2nd one but how can I specify I want the max of the subset of data and not the max of the full data enclosed in the column (i.e. when no filter is not set on 1st column)

Any help greatly appreciated
Regards
Jerome.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Macro : seeking max value after an Autofilter

You can use the SpecialCells method of the Range object
and use the xlCellTypeVisible type.

HTH

TJ
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 94
Default Macro : seeking max value after an Autofilter

Jerome,

Create a formula on the worksheet using the SUBTOTAL function.

If your data is in Column A and B with headers in Row 10 and the data in
Rows 11 to 100 then:
B9: =SUBTOTAL(4,B11:B100)

The value in Cell B9 will recalculate after each AutoFilter and will only
calculate based upon the displayed data. The "4" in the function indicates
to calculate the MAX of the data. See the Excel Help on SUBTOTAL for more
details.

Troy


"Jerome" wrote in message
...
Dear Experts,

My excel sheet encloses 2 columns :
- 1st column is a zip code with Data/Filter/Autofilter on.
- 2nd column is a number
In a macro :
- I filter data of the1st colum using the autofilter (i.e.

Selection.AutoFilter Field:=1, Criteria1:="10080")
- I want then to get the max of the resulting numbers in the 2nd one but

how can I specify I want the max of the subset of data and not the max of
the full data enclosed in the column (i.e. when no filter is not set on 1st
column) ?

Any help greatly appreciated.
Regards,
Jerome.



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 153
Default Macro : seeking max value after an Autofilter

There may be a better way, but one way to do it would be
to copy special, visible and put the copy somewhere. Find
your max on the copied data, store it in a variable, then
erase the copied data.

-----Original Message-----
Dear Experts,

My excel sheet encloses 2 columns :
- 1st column is a zip code with Data/Filter/Autofilter

on.
- 2nd column is a number
In a macro :
- I filter data of the1st colum using the autofilter

(i.e. Selection.AutoFilter Field:=1, Criteria1:="10080")
- I want then to get the max of the resulting numbers in

the 2nd one but how can I specify I want the max of the
subset of data and not the max of the full data enclosed
in the column (i.e. when no filter is not set on 1st
column) ?

Any help greatly appreciated.
Regards,
Jerome.
.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Macro : seeking max value after an Autofilter


I can select using Range("B:B").SpecialCells(xlCellTypeVisible).Selec t
1/ Is it correct to write Range("B:B") to specify I want to select the column B
2/ How can I get the max of the selected data now
Thanks for your help
Jerome

----- tinyjack wrote: ----

You can use the SpecialCells method of the Range object
and use the xlCellTypeVisible type

HT

T



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Macro : seeking max value after an Autofilter

There is no need to use the .Select method, in most cases
you can achieve your desired results by directly dealing
with the objects, so you can use the following

Dim dblAnswer As Double
Dim rngVisible As Range

Set rngVisible = Range("B:B").SpecialCells
(xlCellTypeVisible)

dblAnswer = Application.WorksheetFunction.Max(rngVisible)

HTH

TJ

-----Original Message-----

I can select using Range("B:B").SpecialCells

(xlCellTypeVisible).Select
1/ Is it correct to write Range("B:B") to specify I want

to select the column B ?
2/ How can I get the max of the selected data now ?
Thanks for your help.
Jerome.

----- tinyjack wrote: -----

You can use the SpecialCells method of the Range

object
and use the xlCellTypeVisible type.

HTH

TJ

.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro, AutoFilter... Aline Excel Discussion (Misc queries) 1 July 27th 08 12:27 AM
Autofilter Macro? Danni2004 Excel Discussion (Misc queries) 1 April 29th 08 05:54 PM
AutoFilter Macro carl Excel Worksheet Functions 1 August 20th 07 08:34 PM
Macro using autofilter Lorna B Excel Discussion (Misc queries) 5 May 25th 07 06:54 PM
Keep autofilter after macro is run gmr7 Excel Worksheet Functions 2 July 5th 05 01:16 PM


All times are GMT +1. The time now is 01:45 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"