优化后的代码如下:

Dim lastRow As Long lastRow = Cells(Rows.Count, 'J').End(xlUp).Row '获取A列最后一个非空单元格所在行 Dim valueA As Double, ValueB As Double

valueA = 2468.25 / Range('U3').Value

Range('P1:P' & lastRow).Value = Application.WorksheetFunction.Multiply(Range('J1:J' & lastRow), valueA) '将 P 列当前单元格设为 J 列相应单元格的三倍

VBA 优化:使用 WorksheetFunction.Multiply 简化代码

原文地址: https://www.cveoy.top/t/topic/oh3N 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录