+ Reply to Thread
Results 1 to 4 of 4

Percentile function in VBA, Excel

Hybrid View

  1. #1
    Registered User
    Join Date
    08-26-2013
    Location
    South Africa
    MS-Off Ver
    Excel 2010
    Posts
    2

    Percentile function in VBA, Excel

    I urgently need help to write a VBA code that does the following: I have a list of material numbers. Each material number appears several times in the list (the list is sorted, so all the material numbers that are the same are grouped under another) and next to the material number is a lead time. I want the code to give me the 80th percentile of the lead time of a specific material number.

    Please see the attachment of what i want the code to do.
    Attached Files Attached Files

  2. #2
    Forum Expert Solus Rankin's Avatar
    Join Date
    05-24-2013
    Location
    Hollywood, CA
    MS-Off Ver
    Win7 Office 2010 VS Express 2012
    Posts
    2,655

    Re: Percentile function in VBA, Excel

    Maybe:
    Sub NumbersGoHere()
    
    Dim cel As Range
    Dim strStart As String
    Dim strEnd As String
    
    For Each cel In Range("A2:A" & Range("A" & Rows.Count).End(xlUp).Row)
        If cel.Value <> cel.Offset(-1).Value Then
            strStart = cel.Offset(, 1).Address
            cel.Select
            Do Until ActiveCell.Value <> ActiveCell.Offset(1).Value
                ActiveCell.Offset(1).Select
            Loop
            strEnd = ActiveCell.Offset(, 1).Address
            Range("C" & ActiveCell.Row).Formula = "=Percentile(" & strStart & ":" & strEnd & ",80%)"
        End If
    Next
    
    End Sub
    Thanks,
    Solus


    Please remember the following:

    1. Use [code] code tags [/code]. It keeps posts clean, easy-to-read, and maintains VBA formatting.
    Highlight the code in your post and press the # button in the toolbar.
    2. Show appreciation to those who have helped you by clicking below their posts.
    3. If you are happy with a solution to your problem, mark the thread as [SOLVED] using the tools at the top.

    "Slow is smooth, smooth is fast."

  3. #3
    Registered User
    Join Date
    08-26-2013
    Location
    South Africa
    MS-Off Ver
    Excel 2010
    Posts
    2

    Re: Percentile function in VBA, Excel

    This works perfectly! Thanks sooo much!!

  4. #4
    Forum Expert Solus Rankin's Avatar
    Join Date
    05-24-2013
    Location
    Hollywood, CA
    MS-Off Ver
    Win7 Office 2010 VS Express 2012
    Posts
    2,655

    Re: Percentile function in VBA, Excel

    Glad to help. If you are satisfied with the solution please mark the thread as [SOLVED] using the thread tools at the top.

    Also, on any thread you can show appreciation to those who have helped you by clicking the * Add Reputation below their posts.

    Welcome to the forum.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Conditional percentile: Bug in percentíle function?
    By Duronka in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 08-13-2013, 08:08 AM
  2. Need help with my percentile function.
    By acoron01 in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 08-08-2013, 10:42 AM
  3. [SOLVED] Percentile function that ignores 0s
    By awcwa in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 04-16-2013, 03:26 PM
  4. Help needed with PERCENTILE function
    By dododave in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 02-18-2013, 04:58 PM
  5. array problem in Percentile function
    By mingali in forum Excel General
    Replies: 1
    Last Post: 04-07-2010, 03:39 AM

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