Home > Software engineering >  Vb how to invoke the summation of the excel, on average, and maximum and minimum formula
Vb how to invoke the summation of the excel, on average, and maximum and minimum formula

Time:09-25

Vb how to invoke the summation of the excel, on average, and maximum and minimum formula

CodePudding user response:

To create Excel Application object, then call WorksheetFunction support function through it, So easy...
 'reference code (sample only passed four parameters, these functions are actually support "of" a number of parameters) : 
Private Sub Command1_Click ()
Dim objExcelApp As Object

The Set objExcelApp=CreateObject (" Excel. Application ")
Me. Print "parameters passed: 2, 5, 15, 3"
Me. Print a maximum value: "" & amp; ObjExcelApp. WorksheetFunction. Max (2, 5, 15, 3)
Me. Print a minimum value: "" & amp; ObjExcelApp. WorksheetFunction. Min (2, 5, 15, 3)
Me. Print "summation:" & amp; ObjExcelApp. WorksheetFunction. Sum (2, 5, 15, 3)
Me. Print "mean:" & amp; ObjExcelApp. WorksheetFunction. Business, (2, 5, 15, 3)
The Set objExcelApp=Nothing
End Sub

CodePudding user response:

This a few function to write their own than excel around a circle inside all convenient

CodePudding user response:

references, the start of the second floor bear children reply:
this several functions to write their own than excel around a circle inside all convenient.
and efficiency will certainly be many times higher than this

CodePudding user response:

refer to the second floor WallesCai response:
this several functions to write their own than excel around a circle inside all convenient.

For example:
 Private Function Maximum (ParamArray Vals ()) 
Dim n As an Integer, very
On the Error Resume Next
Very much=Vals (0)
For n=1 To UBound (Vals)
If Vals (n) & gt; Very much Then very=Vals (n)
The Next n
Maximum=very much
End the Function
  • Related