ABCD with different values in different parts, quick summation
CodePudding user response:
How did that picture?CodePudding user response:
Write well, code is as follows:
Option Explicit
The Public Function Calc (ByVal objPartRange As Range, ByVal objFormulaRange As Range) As the Variant
Dim lngCol As Long
LngCol=6
Do
If Cells (1, lngCol)=objPartRange. Value Then
The Exit Do
ElseIf Cells (1, lngCol)="" Then
Calc="E"
The Exit Function
End the If
LngCol=lngCol + 1
Loop
Dim objSC As Object
The Set objSC=CreateObject (" MSScriptControl. ScriptControl)
ObjSC. Language="VBScript"
Dim lngRow As Long
LngRow=2
The Do While Cells (lngRow, 5) & lt;> "
"ObjSC. Executestatement Cells (lngRow, 5) & amp; "=" & amp; Cells (lngRow lngCol)
LngRow=lngRow + 1
Loop
Calc=objSC. Eval (objFormulaRange. Value)
End the Function
Download address:
Link: https://pan.baidu.com/s/1Zz2vi1LQmjvNd1RBPooe7g
The extracted code: sqg1
Run the example:
CodePudding user response:
Thanks to the great god reply!I run not to come out the result, the code has been an error can't run, don't know is where there is a problem
CodePudding user response:
Empty the entire contents, and then copy the code to the window;Or download the sample files I gave you;