这是我想要做的:
我有一个电子表格,其中包含可变数量的行,每个行的长度都是可变的。
包含行的范围在开始和结束时由列A中的标识符标记,格式如下:"#Description“
如前所述,每行的长度(这里的长度=列数)是可变的。对于每一行,我需要遍历每一列,并确定它是否包含用户定义的字符串。
Set firstDesc = ws.Range("A1:A9999").Find("# Description:")
Set secDesc = ws.Range("A1:A9999").Find("# Description:", firstDesc)
Set searchArea = ws.Range(secDesc, secDesc.End(xlToRight))
'grab the name of the node
Dim nodeName As String
nodeName = TextBox1.Value
'Find occurences of the node entered by user
Set Node = searchArea.Find(nodeName)
If Not Node Is Nothing Then
MsgBox "Value Found in Cell " & Node.Address
End If发布于 2013-02-26 03:47:41
在Range.Find方法中设置以下参数:LookAt (xlPart或xlWhole)和LookIn (xlValues或xlFormulas)。这些参数没有默认值;每次使用Range.Find方法时都会保存这些设置。
https://stackoverflow.com/questions/15074502
复制相似问题