2013年8月18日 星期日

VBA - 日期資料顯示轉換

Sub Change_Date_Format()
Dim I, J As Integer
Dim s1 As String

Application.ScreenUpdating = False
For I = 2 To 10

    Sheets("Sheet 1").Select
    s1 = Range("V" & I).Value
    ActiveSheet.Range("V" & I).Select

    If IsNull(Trim(s1)) Or s1 = "" Then
    Else
       ActiveCell.Value = Format(CDate(s1), "yyyy/mm/dd hh:mm:ss")
     
    End If
Next

Application.ScreenUpdating = True
MsgBox "Done"


End Sub