查找特定单元格并使用它来创建范围
Find specific Cell and using it to create a range
我目前正在搜索 excel sheet 以查找特定单元格:
Set findCell = ActiveSheet.Range("D:D").Find(What:=startTerm).Offset(1, 0)
有了这个单元格后,我想创建一个从该单元格向下任意数字的范围,现在没关系了。
Set instrumentList = ActiveSheet.Range("findCell:D100").Cells
我似乎想不出正确的语法。我基本上只需要找到包含一些特定文本的单元格并从中创建一个向下的范围,但我只是收到一个应用程序错误。
您可能想像这样再次使用 Offset()
:(添加了对 startTerm
未找到的检查)
If Not findCell is Nothing Then
Set instrumentList = ActiveSheet.Range(findCell, findCell.Offset(x, 0))
Else
MsgBox startTerm & " Not Found!"
Exit Sub
End If
其中 x
是您想要向下移动的任意行数。
我目前正在搜索 excel sheet 以查找特定单元格:
Set findCell = ActiveSheet.Range("D:D").Find(What:=startTerm).Offset(1, 0)
有了这个单元格后,我想创建一个从该单元格向下任意数字的范围,现在没关系了。
Set instrumentList = ActiveSheet.Range("findCell:D100").Cells
我似乎想不出正确的语法。我基本上只需要找到包含一些特定文本的单元格并从中创建一个向下的范围,但我只是收到一个应用程序错误。
您可能想像这样再次使用 Offset()
:(添加了对 startTerm
未找到的检查)
If Not findCell is Nothing Then
Set instrumentList = ActiveSheet.Range(findCell, findCell.Offset(x, 0))
Else
MsgBox startTerm & " Not Found!"
Exit Sub
End If
其中 x
是您想要向下移动的任意行数。