I am working on the following code, and instead of selecting a range by naming the cells exactly, I changed to a more general way using Cells( , )
However, now, I get a message saying "Type mismatch" but I don't really see what's wrong given that I have only updated the formula to a more general one...
Option Explicit
Option Base 1
Sub dort9()
Dim cMin As Double
Dim cMax As Double
Dim lDer As Long
Dim NoIntervals As Long
Dim plaga() As Variant
Dim I As Long
Dim J As Long
NoIntervals = 5
ReDim Preserve plaga(14)
plaga = Worksheets("Sheet2").Range(Cells(1, 1), Cells(1, 14)).Value
Call tri1(plaga)
cMin = WorksheetFunction.Min(plaga)
cMax = WorksheetFunction.Max(plaga)
Dim longInter As Double
longInter = (cMax - cMin) / NoIntervals
ReDim plaga2(1 To NoIntervals) As Long
ReDim arrintervals(1 To NoIntervals)
Dim pla As Variant
Dim lCom As Long
Dim res As Variant
For I = 1 To NoIntervals
arrintervals(I) = cMax - ((I - 1) * longInter)
Next I
For Each pla In plaga
res = Application.Match(pla, arrintervals, -1)
plaga2(res) = plaga2(res) + 1
Next pla
For J = NoIntervals To 1 Step -1
Worksheets("Sheet2").Range(Cells(2, 1)).Offset(NoIntervals - J) = arrintervals(J)
Worksheets("Sheet2").Range(Cells(3, 1)).Offset(NoIntervals - J) = plaga2(J)
Next J
End Sub
Bookmarks