VBA MOD01 Passing Arguments to sub procedures (ByRef , By Val)

 


Private Sub myCalc(Getvalue As Double, myPercent)

    

    Getvalue = Getvalue * myPercent

    MsgBox Getvalue

    

End Sub


Public Sub GetMyValue()

    Dim myValue As Double

    Dim p As Variant

    'assign value and percentage from cell

    myValue = Range("A8").Value

    p = Range("B8").Value

    Call myCalc(myValue, p)

    MsgBox myValue

    

End Sub




=========================================================================
Private Sub myCalc(Getvalue As Double, myPercent)
    
    Getvalue = Getvalue * myPercent
    MsgBox Getvalue
    
End Sub

Public Sub GetMyValue()
    Dim myValue As Double
    Dim p As Variant
    'assign value and percentage from cell
    myValue = Range("A8").Value
    p = Range("B8").Value
    If Excel.WorksheetFunction.IsNumber(p) Then
        Call myCalc(myValue, p)
     Else
        myCalc myValue, 1
     End If
    MsgBox myValue
    
End Sub














Comments

Popular posts from this blog

VBA01 Copy Resize Variably Sized Ranges

PY MOD01 Lecture 01