0
我有一些代码查看工作表。此代码应查看列A中具有值的所有项目,然后查看右侧的一列,以查看列B中的邻居是否有值。如果B中的值存在,AND与某个标准号相匹配,则A列中的值将被复制到一个集合中(作为ID以稍后显示详细信息)。检查附近单元格是否匹配
If criteriaNumberMatches > 0 Then
'Dim Element As Integer
'goal is to count the number of each unique Bearpass Number, and if its > 3 display user info
Dim totalCorrectHits As Integer
'THIS MAY NOT WORK
'look through the rows of the Extra Interface
For Each cell In Sheet4.Range("A2:A1000")
If Len(cell.Value) <> 0 Then
cellNextDoor = cell.Offset(rowOffset:=0, columnOffset:=1)
'check to see if cell to the right has a value equal to the criteria matches
If Len(cellNextDoor) <> 0 & cellNextDoor = criticaNumberMatches Then
matchBPNcol.Add cell.Value
totalCorrectHits = totalCorrectHits + 1
MsgBox "Commander, we've found something!"
'old code below
'MsgBox cell.Value & "is the cell value, vs " & criteriaNumberMatches & " matches "
'if the criteria hits = the number of criteria, add to collection
'If cell.Value = criteriaNumberMatches Then
'Look one cell left to find the BPN, and add it
'thingToAdd = ActiveCell.Offset(rowOffset:=0, columnOffset:=1)
'THIS ALSO MAY NOT WORK
'matchBPNcol.Add thingToAdd
'totalCorrectHits = totalCorrectHits + 1
End If
End If
Next
Else: MsgBox "No Results Found"
End If
MsgBox "There are " & criteriaNumberMatches & " criteria to match"
MsgBox "The matchBPNcol contains " & matchBPNcol.Count & " positive matches in all criteria"
MsgBox "There are " & totalCorrectHits & " totally unique BPN matches"
因此,到了最后,我发现我的收藏(matchBPNcol
)是空的,我totalCorrectHits
是空的为好。我可能会错误地将右侧单元格定义为右侧。 下图为示例的criteriaNumberMatches = 2
但不触发每个Bearpass数的要被添加到matchBPNcol
VBA'And'运算符是'And':)...在这一行出错了'如果Len(cellNextDoor)<> 0&cellNextDoor = criticaNumberMatches Then''。 '&'用于将字符串连接在一起 – Rosetta
宾果。感谢您的帮助!后来我在关于关系运营商的MS文档中屡屡发现了这一点。 你是一个出色的人!谢谢你! – Sean
指挥官,我们已经找到你的&!! XD – Rosetta