我想问如何从 vba 代码中做到这一点
工作簿 1 包含单元格 A、单元格 B、单元格 C 工作簿 2 包含单元格 D 每个单元格包含数值单元格 D = (单元格 A - 单元格 B) * 单元格 C
我想计算并将值返回到工作簿 2 中的单元格 D,这是我的代码片段
Dim path As String
Dim workbookName As String
Dim worksheetName As String
Dim cella As String, cellb As String, cellc As String
Dim returnedValue1 As String, returnedValue2 As String, returnedValue3 As String
Dim Hasil1 As Long
path = "D:\"
workbookName = "Workbook1"
worksheetName = "Daily"
cella = "F7"
cellb = "E7"
cellc = "D7"
returnedValue1 = "'" & path & "[" & workbookName & "]" & _
worksheetName & "'!" & Range(cella).Address(True, True, -4150)
returnedValue2 = "'" & path & "[" & workbookName & "]" & _
worksheetName & "'!" & Range(cellb).Address(True, True, -4150)
returnedValue3 = "'" & path & "[" & workbookName & "]" & _
worksheetName & "'!" & Range(cellc).Address(True, True, -4150)
Worksheets("Workbook2").Cells(D).Value = CLng(ExecuteExcel4Macro(returnedValue1) - ExecuteExcel4Macro(returnedValue2)) * ExecuteExcel4Macro(returnedValue3)
就我的代码而言,我的代码很好,但是如何在一列中做到这一点,除了单元格 A 之外,我还有很多单元格。我想像这样计算 D 列 =(A 列 - B 列)* COlumn C
感谢您的回答..