|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
一直发愁,如何移植xcel,Ppt的VBA到WPS。实际使用,简单方便,没有任何障碍。
用Split,Left,Mide,Right
- Sub ll()
- Dim Dic As New Dictionary
- Set Dic = New Dictionary
- Dim Rng As Range
- Dim Arr, Str, Str1, ii
- Dim oDate As Date
- Set Rng = Selection.CurrentRegion
- For ii = 1 To Rng.Rows.Count
- 'Debug.Print Rng(ii, 1)
- Arr = Split(Rng(ii, 1), "_")
- Str = Left(Arr(0), 4) & "/" & Mid(Arr(0), 5, 2) & "/" & Right(Arr(0), 2)
- Str1 = Left(Arr(1), 2) & ":" & Mid(Arr(1), 5, 2) & ":" & Right(Arr(1), 2)
-
- oDate = Str & " " & Str1
- Rng(ii, 2) = oDate
- Dic(oDate) = ""
-
- Next ii
-
- For ii = 0 To Dic.Count - 1
- Rng(ii, -2) = Dic.Keys(ii)
- Next ii
- End Sub
复制代码
|
|