我有一个VB脚本,其行如下所示:
Set startCell = referenceCell.EntireColumn.Find(tmp).offset(0,columnOffset)
但我想指定find
(以完全搜索每列中的给定单词)为:
Set startCell = referenceCell.EntireColumn.Find(tmp, lookat:=xlWhole).offset(0,columnOffset)
一切都按照
http://msdn.microsoft.com/en-us/library/office/ff839746(v=office.15).aspx
但是这给了我一个语法错误。 (我讨厌VB)
我也试过
Set tmp = "Precondition" & preconditionNumber
Set startCell = ReferenceCell.EntireColumn.Find(what:=tmp,lookat:=xlWhole).offset(0,columnOffset)
甚至
Set startCell = ReferenceCell.EntireColumn.Find(what:=tmp).offset(0,columnOffset)
没有一个有用。
我该如何调用Find
函数来获取Whole Word
- 搜索?
变量声明如下所示:
Dim startCell
for preconditionNumber = 0 to 15
Set startCell = Nothing
tmp = "Precondition" & preconditionNumber
Set startCell = referenceCell.EntireColumn.Find(tmp).offset(0,columnOffset)
...
这是确切的语法错误消息。
答案 0 :(得分:1)
使用类似:
Sub luxation()
Dim ReferenceCell As Range, rCol As Range, tmp As String
Dim GotIt As Range, MoveOver As Range, columnOffset As Long
Set ReferenceCell = Range("B9")
Set rCol = ReferenceCell.EntireColumn.Cells
tmp = "happiness"
columnOffset = 2
Set GotIt = rCol.Find(what:=tmp, after:=rCol(1), lookat:=xlWhole)
Set MoveOver = GotIt.Offset(0, columnOffset)
MoveOver.Select
End Sub
修复VBA仇恨更加容易,只需重复:
VBA是我的朋友。
每天早上30次