+ Reply to Thread
Results 1 to 7 of 7

VBA to Analyse a row of values

Hybrid View

Macca_GB VBA to Analyse a row of values 09-11-2013, 08:51 AM
MickG Re: VBA to Analyse a row of... 09-11-2013, 09:57 AM
Macca_GB Re: VBA to Analyse a row of... 09-11-2013, 10:17 AM
MickG Re: VBA to Analyse a row of... 09-11-2013, 10:34 AM
Macca_GB Re: VBA to Analyse a row of... 09-11-2013, 10:39 AM
Macca_GB Re: VBA to Analyse a row of... 09-11-2013, 10:45 AM
MickG Re: VBA to Analyse a row of... 09-11-2013, 10:50 AM
  1. #1
    Registered User
    Join Date
    03-25-2010
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    44

    VBA to Analyse a row of values

    The attached spreadsheet contains the rider data for a motocross club. Sheet 1 is the starting sheet, sheet 2 is what I am trying to acheive. Essentially each rider can count their top 8 results which are shown sheet 2 row Q. The dropped cells are highlighted in yellow. Lastly the whole sheet is re-ordered on row Q in descending order. Can this be achieved with a single VBA macro>
    Attached Files Attached Files

  2. #2
    Forum Expert MickG's Avatar
    Join Date
    11-23-2007
    Location
    Banbury,Oxfordshire
    Posts
    2,650

    Re: VBA to Analyse a row of values

    Try this:_
    Sub MG11Sep34
    Dim Rng As Range, Dn As Range
    Dim oSum As Double
    Dim Ac As Integer
    Dim AcRng As Range
    Dim R
    Dim A
    Dim Ray(1 To 8)
    Dim Fd As Boolean
    Set Rng = Range(Range("D4"), Range("D" & Rows.Count).End(xlUp))
    
    For Each Dn In Rng
        Set AcRng = Dn.Resize(, 11)
        For Ac = 1 To 8
            Ray(Ac) = Application.Large(AcRng, Ac)
            oSum = oSum + Application.Large(AcRng, Ac)
        Next Ac
            For Each A In AcRng
                Fd = False
                For Each R In Ray
                    Fd = A = R
                    If Fd = True Then Exit For
                Next R
                If Fd = False Then A.Interior.ColorIndex = 6
            Next A
                Dn.Offset(, 13) = oSum
                oSum = 0
    Next Dn
    Range("A4").Resize(Rng.Count, 17).Sort Range("Q4"), xlDescending
    Range("Q1") = "3 Rounds Dropped"
    End Sub
    Regards Mick
    Last edited by MickG; 09-11-2013 at 10:09 AM.

  3. #3
    Registered User
    Join Date
    03-25-2010
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    44

    Re: VBA to Analyse a row of values

    Mick,

    Run Time Error '13'
    Type Mismatch.
    When I go to debug the following line is highlighted:-

    oSum = oSum + Application.Large(AcRng, Ac)
    It seems to have stopped on the final Rider, none of the lower scores are highlighted and the sum in the last column still contains the same total. The last column now contains the new sums but the row has not been formatted, no headers and it hasnt been sorted.

    Regards
    Last edited by Macca_GB; 09-11-2013 at 10:26 AM. Reason: Pls use code tags around your codes..Thank you.

  4. #4
    Forum Expert MickG's Avatar
    Join Date
    11-23-2007
    Location
    Banbury,Oxfordshire
    Posts
    2,650

    Re: VBA to Analyse a row of values

    Have you got you data sheet open when you run the code !!!
    Try running the code on sheet 3 of your returned Workbook
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    03-25-2010
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    44

    Re: VBA to Analyse a row of values

    Mick,

    Ran as you said same error.

  6. #6
    Registered User
    Join Date
    03-25-2010
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    44

    Re: VBA to Analyse a row of values

    Mick,

    I downloaded the sheet and it worked fine, thank you so much.

    Regards

  7. #7
    Forum Expert MickG's Avatar
    Join Date
    11-23-2007
    Location
    Banbury,Oxfordshire
    Posts
    2,650

    Re: VBA to Analyse a row of values

    You're welcome
    Regrds Mick

+ 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. VBA to Analyse a row of values
    By Macca_GB in forum Excel Programming / VBA / Macros
    Replies: 18
    Last Post: 09-10-2013, 04:21 PM
  2. Analyse-It HELP
    By brantjes in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-21-2009, 01:39 PM
  3. Analyse Data in a Row
    By NeedHelpFast in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-23-2008, 06:05 AM
  4. Analyse one list from another
    By sp3ctre in forum Excel General
    Replies: 2
    Last Post: 05-07-2008, 09:15 AM
  5. [SOLVED] Search and Analyse
    By Ian in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-14-2005, 05:05 PM

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