anyway of tidying this up? (pretty trivial sorry)

grimshaw19

New Member
Joined
Jan 12, 2005
Messages
24
Sub calculatestats2()
With Worksheets("Stats")
.Range("K25").Value = WorksheetFunction.Average(diftemp)
.Range("K26").Value = WorksheetFunction.StDev(diftemp)
.Range("k28").Value = WorksheetFunction.Median(diftemp)
.Range("k29").Value = WorksheetFunction.Mode(diftemp)
.Range("k30").Value = WorksheetFunction.Var(diftemp)
.Range("k31").Value = WorksheetFunction.Kurt(diftemp)
.Range("k32").Value = WorksheetFunction.Skew(diftemp)
.Range("k33").Value = WorksheetFunction.Max(diftemp)
.Range("k34").Value = WorksheetFunction.Min(diftemp)
.Range("k35").Value = WorksheetFunction.Count(diftemp)
.Range("k25:k35").Font.Name = "impact"
.Range("k25:k35").Font.Size = 14
End Sub
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
Not really.

Though, from a maintenance perspective, I would go with just the first cell and then use offsets. That way when it is time to move the results to another region, you only have to update 1 line. Along the lines of
Code:
Sub calculatestats2()
    With Worksheets("Stats").Range("K25")
    .Value = WorksheetFunction.Average(diftemp)
    .Offset(1, 0).Value = WorksheetFunction.StDev(diftemp)
    .Offset(3, 0).Value = WorksheetFunction.Median(diftemp)
    .Offset(4, 0).Value = WorksheetFunction.Mode(diftemp)
    .Offset(5, 0).Value = WorksheetFunction.Var(diftemp)
    'you can do the rest :)
    .Range("k31").Value = WorksheetFunction.Kurt(diftemp)
    .Range("k32").Value = WorksheetFunction.Skew(diftemp)
    .Range("k33").Value = WorksheetFunction.Max(diftemp)
    .Range("k34").Value = WorksheetFunction.Min(diftemp)
    .Offset(10, 0).Value = WorksheetFunction.Count(diftemp)
    With .Resize(11, 1).Font
    .Name = "impact"
    .Size = 14
        End With
        End With
    End Sub
 
Upvote 0

Forum statistics

Threads
1,207,197
Messages
6,077,013
Members
446,250
Latest member
Dontcomehereoften

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