excel - 如何在Excel VBA中编写具有多个条件的OR语句

标签 excel vba

如何在 Excel VBA 中编写具有多个条件的 OR 语句。 我试过了

For i = 1 To 30
a = Sheets("Interface").Range("A" & i).Value
If (Sheets("Interface").Range("A" & i).Value Like "Street*name") Or _
   (UCase(Sheets("Interface").Range("A" & i).Value) Like "Street*address") Or _
   (UCase(Sheets("Interface").Range("A" & i).Value) Like "address") Then
'If a Like "*Street*address*" Then
Sheets("Interface").Range("B" & i).Value = "STREETNAME"
End If
Next i

我用简单的街道*地址语句(注释代码)尝试过,但它没有进入真正的代码。这段代码有什么问题。

最佳答案

类似这样的事情:

For i = 1 To 30

    a = UCase(Sheets("Interface").Range("A" & i).Value)

    If a Like "STREET*NAME" Or a Like "STREET*ADDRESS" Or _
                               a Like "ADDRESS" Then

        Sheets("Interface").Range("B" & i).Value = "STREETNAME"

    End If

Next i

关于excel - 如何在Excel VBA中编写具有多个条件的OR语句,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24029856/

相关文章:

excel - 防止重复项从列表框添加到列表框(VBA excel)

excel - Excel-为什么命名合并范围不同于合并范围然后命名?

Excel - vlookup 值 - 来自另一个工作表的 2 列(无连接)的组合

Excel 逻辑问题

vba - 使用msxml2.xmlhttp.3.0将数据发送到web以选择EXCEL VBA中的Datepicker

vba - Excel 宏,在运行时插入国际有效的公式

sql-server - MS Access 调用 SQL Server 存储过程

python - 编程错误 : can't adapt type 'set'

c# - 尝试将大 Excel 文件读入 DataTable 时出现 OutOfMemoryException

c# - Aspose 或电子表格设备