comparing average results,

montecarlo2012

Well-known Member
Joined
Jan 26, 2011
Messages
984
Office Version
  1. 2010
Platform
  1. Windows
Hello,
From a old post I was trying to make a little adjustments, but I am not really good at it.
this is where my question come from just in case you are intresting to give a hand
VBA - Change a line in a code
and this is the code I would like to adjust.
VBA Code:
Sub forum_Mrexcel()

    Dim rngStart As range, rngData As range, Summary As range
    Dim Diff1 As Long, Diff2 As Long, NoRows As Long, NoCols As Long, i As Long
    Dim s As String
    Set rngData = range("B3:F3000")
    NoRows = rngData.Rows.count
    NoCols = rngData.Columns.count
    Diff1 = 5
    Diff2 = 60
    Set rngStart = range("I3").Resize(, NoCols)
    Set Summary = Worksheets("Sheet8").range("B2").Resize(, NoCols)
    For i = Diff1 To Diff2
        With rngStart.Offset(, (NoCols + 1) * (i - Diff1)).Resize(NoRows - i)
            .Rows(0).Formula = "=SUMPRODUCT(--(" & rngData.Resize(NoRows - i, 1).Address(0, 0) & "=" & .Columns(1).Address(0, 0) & "))"
            .Rows(0).Font.Bold = True
            .Formula = "=TRUNC(Average(" & rngData.Resize(i + 1, 1).Address(0, 0) & "))"
            Summary.Rows(i + 1 - Diff1).value = .Rows(0).value
            s = .Cells(1, 1).Address(0, 0)
            With .FormatConditions
                .Delete
                .Add Type:=xlExpression, Formula1:="=" & rngData(1, 1).Address(0, 0) & "=" & s
                .Item(1).Interior.COLOR = vbYellow
            End With
        End With
    Next i

End Sub
Now my dynamic array is 5 x 8636, the original code is designed for a 6 x 2300
so the little changes I made was:
Set rngData = range("B3:F3000")

Diff1 = 5

Set Summary = Worksheets("Sheet8").range("B2").Resize(, NoCols)
so work, but, highlight the wrong areas and do not paste the values.

Please, some help would be really appreciated
thanks for taking your time and reading this.
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.

Forum statistics

Threads
1,215,174
Messages
6,123,454
Members
449,100
Latest member
sktz

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