create a 24*30 matrix from a 100*30 matrix excel vba -
i have looked , didn't found suits problem.
so, have 100*30 matrix , want make average of first 4 elements in first row, average of next elements in first row , on.
from this, i'll have 24*30 matrix. i've done that, mt log paste results spaced 4 elements.
how can create matrix ?
here's code:
private sub commandbutton1_click() dim media_horaria long dim hora long media_horaria = 0 hora = 0 sheets("folha1") = 28 58 j = 3 100 step 3 hora = cells(i, j).value + cells(i, j + 1).value + cells(i, j + 2).value + cells(i, j + 3).value media_horaria = hora / 4 cells(i + 45, j).value = media_horaria next j media_horaria = 0 hora = 0 next end end sub
edit:
with result matrix, create colour map depending on cell value. instance, if cell value under 0.5 , above 0.45 paint in light red. if cell above 0.50 , under 0.55 paint in dark red. legend under matrix. top level having picture.
this code snippet creating conditional formatting rules fit existing sub or run another.
with sheets("folha1").cells(73, 3).resize(31, 33) .formatconditions.delete .formatconditions.add type:=xlexpression, formula1:="=and(rc>=0.45,rc<0.5)" .formatconditions(.formatconditions.count).interior .patterncolorindex = xlautomatic .colorindex = 3 end .formatconditions.add type:=xlexpression, formula1:="=and(rc>=0.5, rc<0.55)" .formatconditions(.formatconditions.count).interior .patterncolorindex = xlautomatic .colorindex = 9 end .cells(.rows.count, 1).offset(2, 1) = "legend" .cells(.rows.count, 1).offset(3, 0).interior.colorindex = 3 .cells(.rows.count, 1).offset(3, 1) = chrw(8805) & "0.45 , <0.5" .cells(.rows.count, 1).offset(4, 0).interior.colorindex = 9 .cells(.rows.count, 1).offset(4, 1) = chrw(8805) & "0.5 , <0.55" end
the row , column references may have adjusted according final data resides. if unhappy color choices, record macro of setting cell colors , use .color =
instead of limited palette of .colorindex =
.
Comments
Post a Comment