Sunday, 3 January 2016

Basic Fun

If you have ever wanted to automate your calculations to save on time Excel VBA can do wonders. Check this out.


Its very simple and very basic. The macros used in the video are below. Feel free to use it.
_________________________________________________________

Sub Average()

    ActiveCell.FormulaR1C1 = "=AVERAGE(RC[-2]:R[2]C[-2])"
    ActiveCell.Select
    Selection.Copy
    ActiveCell.Offset(3, 0).Range("A1").Select
    ActiveSheet.Paste
    ActiveCell.Offset(3, 0).Range("A1").Select
    ActiveSheet.Paste
    ActiveCell.Offset(3, 0).Range("A1").Select
    ActiveSheet.Paste
    
End Sub
_________________________________________________________

Sub SD()

    ActiveCell.FormulaR1C1 = "=STDEV(RC[-4]:R[2]C[-4])"
    ActiveCell.Select
    Selection.Copy
    ActiveCell.Offset(3, 0).Range("A1").Select
    ActiveSheet.Paste
    ActiveCell.Offset(3, 0).Range("A1").Select
    ActiveSheet.Paste
    ActiveCell.Offset(3, 0).Range("A1").Select
    ActiveSheet.Paste
End Sub
_________________________________________________________

Sub SEM()

    ActiveCell.FormulaR1C1 = "=RC[-2]/SQRT(3)"
    ActiveCell.Select
    Selection.Copy
    ActiveCell.Offset(3, 0).Range("A1").Select
    ActiveSheet.Paste
    ActiveCell.Offset(3, 0).Range("A1").Select
    ActiveSheet.Paste
    ActiveCell.Offset(3, 0).Range("A1").Select
    ActiveSheet.Paste
End Sub
_________________________________________________________

Sub ClearCalculations()

Range("d3:i12").Select
    Selection.clear
        
Cells(1, 1).Select

End Sub
_________________________________________________________

Sub Instructions()

MsgBox "Select the cell you want the calculations to start from then move the cursor to the button. Click and enjoy :D"

End Sub
_________________________________________________________

No comments:

Post a Comment