vba - 使用多个条件查找价值
问题描述
我需要根据 2 个标准在 Excel 工作表中找到一个值。Find 方法仅支持一个条件。有没有其他功能?例如有 2 列。我需要在 A 列中找到 ABC,其中 B 列中的值为 10。
谢谢您的帮助
解决方案
想到的第一种方法。我相信还有其他方法,可能更好。
'VBA Loop Not exactly recommended if the file is long
Set wk = ThisWorkbook
With wk.Sheets("SheetName")
lastRow = .Cells(Rows.Count, 1).End(xlUp).Row
For i = 1 to lastRow
aString = .Cells(i, 1).Text
bString = .Cells(i, 2).Text
If aString & bString = "ABC10" Then
MsgBox "Found at Row: " & i
Exit For
End If
Next i
End With
推荐阅读
- xml - 循环通过 xml 并仅获取选择项
- python - Python - 合并两个有条件的数据框
- android - BottomNavigationView,上一个片段上TextView的onFocusChange仅在新片段上的onResume之后调用
- graphql - 图 QL 对实体中不同对象的逻辑与运算
- pandas - 选择一些数据框python pandas的列
- azure-devops - Azure DevOps Pipeline 未下载参考
- asp.net-core - 应用程序不拾取 blazorclasslib 页面
- javascript - 无论外部变量如何变化,如何在函数中引用自身?
- javascript - 在nodejs中导入JS类的问题
- r - 使用 %in% 创建 id