+ Reply to Thread
Results 1 to 9 of 9

Max-Min

Hybrid View

  1. #1
    Registered User
    Join Date
    05-11-2005
    Posts
    5

    Tried it

    Mrshorty,

    I have tried this approach and it doesnt make it. When the data stream ends the solution has to be converted to text or number. Up to that point MAX min() works with the same short comings. Your solution still relies on the loop and when one variable drops out the whole thing crashes.

    Robk

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259
    Hello Kierco,

    Here is a code routine that may prove helpful. Whenever the data stream changes the cells value, the worksheet will compare it against the previous Min and Max values. These values are stored on the worksheet. This way you always have the most current Min and Max values, regardless of the data stream's timing. You will have to provide the code that determines when the stream ends. At that time you can simply retrieve the Min and Max values from the worksheet.

    Copy and Paste this code in the Worksheet where your data value will be stored. The code is set to capture the Value in "A1" with Min in "B2" and Max in "C2". You can easily change these in the code to match your needs

    Private Sub Worksheet_Change(ByVal Target As Excel.Range)
    
    'Track Min and Max Values of a Cell
     
     Dim ValCell
     Dim MinCell As Range
     Dim MaxCell As Range
      
      ValCell = "$A$2"
      Set MinCell = Range("B2")
      Set MaxCell = Range("C2")
      
      With Target
       If .Address = ValCell Then
       
        If MinCell.Value = "" And MaxCell.Value = "" Then
         MinCell.Value = Target.Value
         MaxCell.Value = Target.Value
        End If
       
        Select Case .Value
         Case Is >= MaxCell.Value
          MaxCell.Value = .Value
         Case Is <= MinCell.Value
          MinCell.Value = .Value
        End Select
        
       End If
      End With
     
    End Sub


    If you have problems with the code or have any questions, contact me via e-mail at LeithRoss@aol.com.

    Sincerely,
    Leith Ross
    Last edited by Leith Ross; 05-12-2005 at 06:35 AM.

  3. #3
    Forum Expert swatsp0p's Avatar
    Join Date
    10-07-2004
    Location
    Kentucky, USA
    MS-Off Ver
    Excel 2010
    Posts
    1,545
    My thanks to MrShorty and Leith for responding to my 'plea' for help on this one. Thanks, guys.

    Bruce
    Bruce
    The older I get, the better I used to be.
    USA

  4. #4
    Registered User
    Join Date
    05-11-2005
    Posts
    5

    Many Thanks

    I want to openly thank everyone who has helped get me to this point.
    I will follow instructions and report back with my success and or frustrations. Ha
    Again, many thanks to all.

    kierco

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1