Progs
Progs
Sub clear()
Worksheets(1).Cells.clear
End Sub
If IsNumeric(num) Then
MsgBox "Number"
Else
MsgBox "Text"
End If
End Function
Sub animation()
Dim i As Integer
For i = 1 To 1000
Range("a1").Delete
Next i
End Sub
If s = "add" Then
c = a + b
arithmetic = c
End Function
' Ex - 3: title: arithmetic mean
' objective: to write a program to compute arithmetic mean
'program
Sub arithMean()
Set r = Range("a1:a10")
For Each c In r
sum = sum + c.Value
Next c
avg = sum / 10
MsgBox avg
End Sub
Sub arraySum()
sum = 0
For i = 1 To 10
arr(i) = i
sum = arr(i) + sum
Next i
MsgBox sum
End Sub
Sub confInt()
Set r = Range("a1:a10")
myMean = WorksheetFunction.Average(r)
myStd = WorksheetFunction.StDev(r)
End Sub
Dim sp As Double
Dim n As Integer
sp = WorksheetFunction.Product(rng)
n = WorksheetFunction.Count(rng)
GeoMean = WorksheetFunction.Power(sp, 1 / n)
End Function
' Ex: 6: title: calculate HM
' Objective: to know as how to use worksheet functions to
calculate means
' Statements: worksheetFunction[product, count], range, filldown
Sub harMean()
Dim lr As Integer
lr = Cells(Rows.Count, "A").End(xlUp).Row
Range("b2").Formula = "=1/a2"
Range("b2:b" & lr).FillDown
End Sub
Sub arraySum()
sum = 0
For i = 1 To 10
arr(i) = i
sum = sum + arr(i)
Next i
MsgBox sum
End Sub
Sub harMean()
Dim lr As Integer
Dim sumres As Variant
lr = Cells(Rows.Count, "A").End(xlUp).Row
Range("b2").Formula = "=1/a2"
Range("b2:b" & lr).FillDown
MsgBox lr / sumres
End Sub
Sub harMean()
Dim lr As Integer
Dim sumres As Variant
lr = Cells(Rows.Count, "A").End(xlUp).Row
Range("b2").Formula = "=1/a2"
Range("b2:b" & lr).FillDown
lr = lr + 1
MsgBox lr / sumres
End Sub
Sub summaryCh()
Cells("a11").Value = WorksheetFunction.Average("a2:a10")
Cells("a12").Value = WorksheetFunction.Min("a2:a10")
Cells("a13").Value = WorksheetFunction.Max("a3:a10")
End Sub