如何在VBA中指定列?

时间:2017-07-20 17:00:44

标签: excel-vba vba excel

For Each c In Range("A2:A157")
    If (Left(c, 1) = "P" Or Left(c, 1) = "T") And IsNumeric(Right(c, 6)) And Len(c) >= 5 Then
        c = "Found It" 'i know this overwrites the value
    End If
Next c

我想写"发现它"在同一行但列E

我无法解决这个问题。

2 个答案:

答案 0 :(得分:5)

使用.Offset

For Each c In Activesheet.Range("A2:A157")
    If (Left(c, 1) = "P" Or Left(c, 1) = "T") And IsNumeric(Right(c, 6)) And Len(c) >= 5 Then
        c.Offset(,4) = "Found It" ' i know this overwrites the value
    End If
Next c

答案 1 :(得分:3)

使用:

Range("E" & c.Row).Value = "Found It"