Results 1 to 9 of 9

Using the "usedrange" to insert smallest value in array separated by a word

Threaded View

  1. #1
    Registered User
    Join Date
    10-04-2014
    Location
    Lusaka
    MS-Off Ver
    2007
    Posts
    4

    Red face Using the "usedrange" to insert smallest value in array separated by a word

    I have a column with numbers and the word "Null" between these numbers. For a particular array, I want a code which puts in each row of that array the array's smallest number. E.g the column looks like this
    Null
    52
    48.4
    36.9
    Null
    Null
    Null
    Null
    12
    17
    25.0
    26.6
    29.4
    Null
    Null
    Null

    And the result starts with "" because of the Null above followed by the smallest value of 36.9176 for the first array and then 12 for the last. The gaps represent the position of the "Null" word.

    36.9
    36.9
    36.9




    12
    12
    12
    12
    12


    I have tried the codes but to no avail. Please anyone to help.

    Moderator's note: Please take the time to review our rules. There aren't many, and they are all important. Rule #3 requires code tags. I have added them for you this time because you are a new member. --6StringJazzer

    Sub Smallest()
    Dim rng As Range
    Dim minimum As Double
    Application.Volatile
    Set rng = Intersect(rng.Parent.UsedRange, rng)
    minimum = Application.WorksheetFunction.Min(rng)
    Range = ("X9:X24")
    MsgBox minimum
    
    End Sub

    OR
    Function minimum(Rng As Range) As Double
        Dim Cell As Range
        Dim Cnt As Long
        Dim Mina As Double    
        Application.Volatile    
        Set Rng = Intersect(Rng.Parent.UsedRange, Rng)        
        For Each Cell In Rng
            If Cell.Value > 0 Then
                Cnt = Cnt + 1
                Mina = Cell.Value            
        Else
           If Cell.Value < Mina Then
              Mina = Cell.Value
             Else
             If Cell.Value = "Null" Then
             Mina = ""    
         End If    
           Cnt = 0
           minimum = Mina
       End If
       End If
       
    Next
    
    End Function
    Last edited by 6StringJazzer; 10-07-2014 at 07:57 PM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 5
    Last Post: 01-23-2014, 11:02 AM
  2. [SOLVED] How to insert + sign in front of every word =Substitute(A3," "," +")
    By inayet in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 03-16-2013, 09:41 PM
  3. [SOLVED] How to Count number of "Error" and "OK" after the word "Instrument" found in table row
    By eltonlaw in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-17-2012, 06:26 AM
  4. array with "separated" data column
    By neeshu in forum Excel General
    Replies: 1
    Last Post: 10-29-2011, 04:07 PM
  5. [SOLVED] If changed array formula reduce ""\""\""\ - signs to #Missing, will it make ...
    By Maria J-son in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-05-2006, 08:25 AM

Tags for this Thread

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