montecarlo2012
Well-known Member
- Joined
- Jan 26, 2011
- Messages
- 984
- Office Version
- 2010
- Platform
- 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.
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.
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
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.