首页 文章

条件连接和自动填充与相邻列的值

提问于
浏览
0
Sub Concatenate ()  
    Dim LastRow As Long  
    Dim i As Long  
        LastRow = Range("A" & Rows.Count).End(xlUp).Row  
            ActiveSheet.Range("K2").Formula = "= TODAY() - I2"
            Range("K2").Select  
            Selection.AutoFill Destination:=Range("K2:K" & LastRow)  
        For i = 2 To LastRow  
            If Range("K" & i).Value < 5 Then Range("J2:J" & i).Value = "Week of" & "" & ("I2:I" & i)  
        Next i  
End Sub

我有一个电子表格,其中列出了A列中的项目编号,以及列I中的相应日期 . 并非每个项目都有日期,所以我基于A列的LastRow来解决这些问题 . 我希望过去的日期在第J列中返回0.我希望将来的日期返回“__周”,__是第I列中的日期 .

我不是最熟悉的VBA,而且我遇到了一些障碍 . 有了上述,一切都回归“9周” . 我知道这是一个简单的答案,但我已经谷歌搜索了一个小时 . 我只需要知道语法,使得上面在连接结束时返回“I”的值,因为它循环了行 . 如果这是一个重复的问题,我道歉 .

提前致谢 .

1 回答

  • 0

    也许你的病情应该是:

    If Range("K" & i).Value < 5 Then Range("J" & i).Value = "Week of " & Range("I" & i)
    

相关问题