传递两个范围作为参数并执行excel工作表

时间:2018-03-12 18:19:45

标签: excel vba excel-vba excel-formula parameter-passing

我正在尝试创建一个将两个范围作为参数传递的函数,代码看起来像这样:

    Function WhatEverFunction(range1 As Range, range2 As Range) As Integer

         Dim column As ingeter
         column = range1.Column
         'make some stuff with the column

         WhatEverFunction = range1.Value + range2.Value
    End Function

这是我执行代码并传递参数的方式: enter image description here

但这是结果: enter image description here

1 个答案:

答案 0 :(得分:1)

以下是其中一些更正。另外,你真的只是做SUM,所以可以考虑以下几点:

{% block _manufacturer_datagrid_widget %}
    {% import 'OroDataGridBundle::macros.html.twig' as dataGrid %}
    {% block content %}
         {{ dataGrid.renderGrid('app-resumes-grid') }}
    {% endblock %}
{% endblock %}

注意@john Coleman关于udf不能做什么的评论。为了明确,UDF会向放置它的单元格返回一些内容。

您的本地设置可能需要 Public Function WhatEverFunction(ByVal range1 As Range, ByVal range2 As Range) As Long Dim myColumn As Long myColumn = range1.column 'make some stuff with the column WhatEverFunction = Application.WorksheetFunction.Sum(range1, range2) End Function