【发布时间】:2019-07-20 10:02:12
【问题描述】:
我需要根据几个包含可变数据的工作簿上的相关单元格的值来定位给定的单元格编号(例如 C100)。一旦我定义了两个这样的单元格编号——一个范围——我将需要这些单元格中包含的值的平均值。
这里是设置,可以正常工作。
' Perform "FIND" function for the first case of "LOCAL PEAK". Note: Since column D is composed of the above formula, the
' find function only recognizes the VALUES in column E
Set found = ActiveSheet.Cells.Find(What:="LOCAL PEAK", After:=[e1], LookIn:=xlValues, _
LookAt:=xlPart, SearchOrder:=xlByColumns, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=True)
' Assign the row number associated with the first instance of "LOCAL PEAK" to the variable "StaticRow"
If Not found Is Nothing Then StaticRow = found.Row
' Assign the value in the cell of the force column associated with the first instance of "LOCAL PEAK" to the variable "SForce"
SForce = Cells(StaticRow, 3).Value
' Assign the value in the cell of the position column associated with the first instance of "LOCAL PEAK" to the variable "InitialPos"
InitialPos = Cells(StaticRow, 2).Value
' Assign the rows for Kinetic Friction calculation
KineticRowA = StaticRow + 60
KineticRowB = StaticRow + 300
继续我尝试但不起作用的方法:
CellA = Cells(KineticRowA, 3)
CellB = Cells(KineticRowB, 3)
KForce = WorksheetFunction.Average(Range(CellA, CellB))
上述方法将 VALUES 分配给变量 CellA 和 CellB,而不是单元格位置。
下一个完全不起作用:)
KForce = WorksheetFunction.Average(Range("CKineticRowA:CKineticRowB"))
谢谢!
【问题讨论】: