我正在使用此循环来查找值。找到工作,但findNext不会,省略许多值。在这里我放下我的代码,你有什么建议吗?非常感谢你!!。在循环中找到下一个不工作
For Each ws In SourceWb.Worksheets
If IsNumeric(Left(ws.Name, 3)) Then
Set gCell = ws.Columns(6).Find(what:=numdoc, LookIn:=xlValues, lookat:=xlWhole, SearchOrder:=xlByRows, MatchCase:=False, searchformat:=False)
If Not gCell Is Nothing And IsNumeric(Left(gCell.Parent.Name, 3)) Then
firstAddress = gCell.Address
Do
repetidos = repetidos + 1
finalcell = gCell.Address
'merged cells code here not displayed
oldaddress = gCell.Address
'>Having trouble here> **
Set gCell = ws.Columns(6).FindNext(after:=gCell)
'**
Loop Until gCell.Address = oldaddress
End If
End If
Next ws
这是为你编译的吗?我得到一个'没有For'编译错误。 – 2014-10-20 09:00:51
是的,确实如此,如果在发帖时尝试删除以下代码语句:if firstAddress <> oldaddress Then – Chakal 2014-10-20 09:09:05
您是如何声明变量的?我不认为这是问题,但我很难复制你的问题。你看过你的“Do ... Loop”中的逻辑吗? – 2014-10-20 09:53:28