طريقة استخدام الدوال العادية فى البرمجه

يمكنك استخدام دوال الاكسل المعتاده فى VBA
Application.WorksheetFunction.Function Name ( function arguments )



مثال على استخدام الدالة SUM
Sub Sum_Fun()
Dim Total As Range
Set Total = ThisWorkbook.Sheets("Sheet1").Range("f3:f28")
Dim Result As Double
Result = Application.WorksheetFunction.Sum(Total)
ThisWorkbook.Sheets("Sheet1").Range("h7").Value = Result
End Sub



مثال على استخدام الدالة vlookup
Sub Vlookup_Fun()
Dim Customer As String
Dim Lookup_Range As Range
Dim Units_Number As Double
Customer = ThisWorkbook.Sheets("Sheet1").Range("j3").Value
Set Lookup_Range = Range("b3:f28")
Units_Number = Application.WorksheetFunction.VLookup(Customer, Lookup_Range, 3, False)
ThisWorkbook.Sheets("Sheet1").Range("k3").Value = Units_Number
End Sub