转换日期在excell到文本vith vba

时间:2018-01-30 08:13:01

标签: excel-vba vba excel

我希望我的代码可以执行类似的操作,但我无法找到正确的代码

Sub InsertDateAsFormulaASText()

Dim WSD As Worksheet
Set WSD = Worksheets("TEST")

FinalRow = Cells(Rows.Count, 1).End(xlUp).Row
' Run trough all rows and set values in coloumn A

    For i = 2 To FinalRow

        ' If value in column 3 are = "Intern Audit" then
        If Cells(i, 3) = "Intern Audit" Then
            ' Insert in column 4 the date from Column 1 as text
            Cells(i, 4).Select
            ActiveCell.FormulaR1C1=TEXT(RC[-3],"åååå") ' This is the part that failed

        Else
            ' Insert in column 4 the date from Column 2 as text
            Cells(i, 4).Select
            ActiveCell.FormulaR1C1=TEXT(RC[-2],"åååå") ' This is the part that failed
        End If
    Next i

End Sub

0 个答案:

没有答案