Formula Question

jmharm

New Member
Joined
Mar 16, 2009
Messages
2
Hello,
I need help constructing an excel spreadsheet formula that will drop the two lowest numbers from each row and average the remaining total in the the final column of each row. (for grading).

Thank you for your help,

Josh
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
You didn't provide sufficient information.

You can edit and/or extend the following:

=(SUM(L4:V4)-SUM(SMALL(L4:V4,{1,2})))/9
 
Upvote 0
Code:
Private Sub mySub()
    Dim row As Integer, col As Integer
    row = 1
    col = 1
    
    Dim tmp As Integer
    
    Dim i As Integer
    Dim delcol As Integer
    delcol = 1
    
    For i = 0 To 1
    tmp = CInt(Sheet1.Cells(row, col).Value)
        While Sheet1.Cells(row, col).Value <> ""
            If tmp > CInt(Sheet1.Cells(row, col).Value) Then
                tmp = CInt(Sheet1.Cells(row, col).Value)
                delcol = col
            End If
            col = col + 1
        Wend
        
        Sheet1.Columns(delcol).Delete
    Next
    
    col = 1
    Dim sum As Integer
    sum = 0
    Dim avg As Double
    avg = 0
     While Sheet1.Cells(row, col).Value <> ""
            sum = sum + Sheet1.Cells(row, col).Value
            col = col + 1
    Wend
    
    avg = sum / col
    Sheet1.Cells(row, col).Value = avg
    
End Sub
 
Upvote 0

Forum statistics

Threads
1,213,549
Messages
6,114,264
Members
448,558
Latest member
aivin

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top