excel - 将 2 个范围相乘
问题描述
我在该行中遇到语法错误
Range("E4:E" & ColALastRow) =Application.WorksheetFunction.Product=(Range("A4:A" & ColALastRow), Range("D4:D" & LastRowOfD))
Col A 和 Col D 有值。我想将它们相乘到 col E。下面是我到目前为止的代码。
Dim rngData As Range
Dim ColALastRow As Long, LastRowOfD As Long
ColALastRow = Cells(Rows.Count, "A").End(xlUp).Row
Set rngData = ActiveSheet.Range("A4:A" & ColALastRow)
LastRowOfD = Cells(Rows.Count, "D").End(xlUp).Row
Range("E4:E" & ColALastRow) =Application.WorksheetFunction.Product=(Range("A4:A" & ColALastRow), Range("D4:D" & LastRowOfD))
解决方案
您可以像下面这样简化您的方法并获得所需的结果。
Sub ProductofTwoCol()
With Range("E1:E" & Cells(Rows.Count, "A").End(xlUp).Row)
.Formula = "=A1*D1"
.Value = .Value
End With
End Sub
推荐阅读
- docker - Docker容器无故丢失
- typescript - 打字稿:使用动态字段名称获取唯一的值列表
- django - api端点中的符号是什么意思?
- vue.js - NuxtJS - 管理多个 axios 实例
- instagram - 在授权 Instagram 基本显示 API 时,如何最好地处理未在其 Instagram 帐户上设置出生日期的用户
- integromat - Integromat 和谷歌验证
- symfony - 要求不能使用 easyAdmin 在我的表单中工作
- asp.net-mvc - EF6 是否存在不保留到 db 的边缘情况,但没有抛出异常
- selenium - Selenium:在一台机器上运行多个 chromedriver 实例时出现稳定性问题
- javascript - 在 html 元素和 js 函数上添加可选的更改事件