当联合IF句中的范围不起作用时

时间:2019-03-25 13:56:07

标签: if-statement range union sentence

我试图查看多个范围,并用if语句检查每个单元格,以便用单词替换字母,例如如果单元格显示为“ AR”,则将其替换为“ Night”。如果我说Range(“ D10:D40”),但如果我说Union(Range(“ D10:D40”),Range(“ L10: L40“),Range(” T10:T40“)...然后显示“类型不匹配”错误2042 ...

 For Each cell In Range("D10:D40")
    If cell.Value = "NR" Then
        cell.Value = "Nat"
    End If
Next cell

 For Each cell In Union(Range("D10:D40"), Range("L10:L40"), Range("T10:T40"), Range("D49:D79"), Range("L49:L79"), Range("T49:T79"), Range("D88:D117"), Range("L88:L117"), Range("T88:T117"), Range("D127:D153"), Range("L127:L157"), Range("T127:T157"))
    If cell.Value = "AR" Then
        cell.Value = "Aften"
    End If
Next cell

0 个答案:

没有答案