提问人:kca062 提问时间:11/10/2023 更新时间:11/10/2023 访问量:47
如何定义某个范围内的地址/单元格位置
How to define an address/cell location thats in a range
问:
我正在尝试编写代码,该代码基本上为我执行线性插值并将结果吐出到电子邮件中。我已将第一列和顶行设置为它们自己的范围(不包括 3300)。每个都需要用户输入每个范围内的数字。正在对顶行执行插值。目前,我正在使用 Excel 查找工作表函数来查找用于插值的 x1。我的计划是然后使用 x1 的地址/单元格位置来获取所需的剩余插值值(x2、y1、y2),但我无法弄清楚在使用变量找到它时如何定义它的位置。
我目前只附加了代码的地址相关组件,但如果需要,我可以复制粘贴整个函数,谢谢!
Dim avgSourceActivity As Double, ContainerActivity As Double, NumbSources As Integer
NumbSources = ws1.Range("D9").Value
'defining search ranges and variable locations
Dim avgSourceActRange As Range
Set avgSourceActRange = ws2.Range("h5:af5")
Dim numbSourcesRange As Range
Set numbSourcesRange = ws2.Range("G6:G19")
ws1.Range("D12").Value = avgSourceActivity
'searches the first column for the value of NumbSources
Dim FoundSourceNumb As Range
Set FoundSourceNumb = Range(numbSourcesRange).Find(NumbSources)
'establishes bounds of source activity for linear interpolation
Dim LookupFormulaMin As Double, LookupFormulaMax As Double
LookupFormulaMin = WorksheetFunction.Lookup(avgSourceActivity, avgSourceActRange)
MsgBox (LookupFormulaMin)
'write something in here to define LookUpFormulaMin's cell location
'use it to get the x2 by shifting over one in the cell range
LookupFormulaMax = ws2.Cells(LookupFormulaMin.Row, LookupFormulaMin.Column + 1).Value
MsgBox (LookupFormulaMax)
答: 暂无答案
评论
avgSourceActivity = ws1.Range("D12").Value
.Row
.Column
.Row
.Column
rng.Value