Consulting

Results 1 to 4 of 4

Thread: Solved: Find the min or Max value in an autofiltered range

  1. #1
    Moderator VBAX Wizard Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    5,060
    Location

    Solved: Find the min or Max value in an autofiltered range

    I am trying to find by formula or vba, the earliest and or latest date in a autofiltered range with the data residing in cells G11 to last row.
    Remember To Do the Following....
    Use [Code].... [/Code] tags when posting code to the thread.
    Mark your thread as Solved if satisfied by using the Thread Tools options.
    If posting the same issue to another forum please show the link

  2. #2
    VBAX Tutor Philcjr's Avatar
    Joined
    Jul 2005
    Location
    Bedminster, NJ
    Posts
    208
    Location
    I am assuming that you have the coding done for the AutoFilter:

    Does this help?

    [vba]
    Dim EarliestDate As Date, LatestDate As Date

    With Application.WorksheetFunction
    EarliestDate = .Min(Range("G:G").SpecialCells(xlCellTypeVisible))
    LatestDate = .Max(Range("G:G").SpecialCells(xlCellTypeVisible))
    End With

    [/vba]

  3. #3
    VBAX Tutor Philcjr's Avatar
    Joined
    Jul 2005
    Location
    Bedminster, NJ
    Posts
    208
    Location
    or if you only want to zero in on G11 to LastRow

    [vba]
    Dim LastRow As Long, EarliestDate As Date, LatestDate As Date

    LastRow = Cells(Rows.Count, "G").End(xlUp).Row

    With Application.WorksheetFunction
    EarliestDate = .Min(Range("G11:G" & LastRow).SpecialCells(xlCellTypeVisible))
    LatestDate = .Max(Range("G11:G" & LastRow).SpecialCells(xlCellTypeVisible))
    End With
    [/vba]

  4. #4
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Max: =SUBTOTAL(104,OFFSET(G11,,,COUNTA(G:G)-COUNTA(G1:G10),1))

    Min: =SUBTOTAL(105,OFFSET(G11,,,COUNTA(G:G)-COUNTA(G1:G10),1))
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •