将格式化日期添加到concat函数的末尾

时间:2015-05-07 12:34:20

标签: excel vba date format concat

我目前正在寻找以DD / MM格式添加更新日期到当前由现有宏生成的文本字符串的末尾。

Sub Nomediatidy()

 Dim w1 As Worksheet
 Dim w2 As Worksheet
    Dim result As Range
    Dim FirstRow As Integer


    Set w1 = Worksheets("Sheet1")
    Set w2 = Worksheets("Master List")

    FirstRow = 0

    With w1.Range("F:F")
        Set result = .Find(What:="No Media", LookIn:=xlValues, LookAt:=xlPart)

        If Not result Is Nothing Then
            FirstRow = result.Row
            Do
                w1.Range("H" & result.Row) = w1.Range("F" & result.Row) + " Available - PAM/Edit to Advise " & w1.Range("H" & result.Row)
                Set result = .FindNext(result)
            Loop While Not result Is Nothing And result.Row <> FirstRow
        End If
    End With

    Set w1 = Nothing
    Set result = Nothing


Application.ScreenUpdating = True

End Sub

在显示“可用 - PAM /编辑建议”的行上,我想添加今天的日期。但是我不能为我的生活找出如何在没有调试器的情况下解决问题。我可能只是在想它,但任何建议都会受到赞赏

1 个答案:

答案 0 :(得分:0)

更改 w1.Range("H" & result.Row) = w1.Range("F" & result.Row) + " Available - PAM/Edit to Advise " & w1.Range("H" & result.Row)

w1.Range("H" & result.Row) = w1.Range("F" & result.Row) & " Available - PAM/Edit to Advise " & w1.Range("H" & result.Row) & " " & format(now, "DD/MM")

这将在您到目前为止的末尾添加一个空格,然后在now函数的当前日期后跟随它,该函数从系统时钟获取日期和时间。然后将其格式化为“DD / MM”