本帖最后由 gufengaoyue 于 2013-12-6 11:10 编辑
一个Format比较有趣的用法
- Sub Test()
- Dim ARR, Tmp$
- ARR = Range([b1], [a65536].End(3))
- For a = 1 To UBound(ARR)
- Tmp = Replace(Left(ARR(a, 1), 14), "-", "")
- For i = Len(Tmp) - 2 To 1 Step -2
- Tmp = Format(Tmp, String(i, "&") & ":")
- Next
- ARR(a, 2) = Tmp
- Next
- [b1].Resize(UBound(ARR), 1) = Application.Index(ARR, , 2)
- End Sub
复制代码- Sub Test()
- Dim ARR, Tmp$
- ARR = Range([b1], [a65536].End(3))
- For a = 1 To UBound(ARR)
- ARR(a, 2) = Replace(Left(ARR(a, 1), 14), "-", "")
- Tmp = WorksheetFunction.Rept("&&:", Len(ARR(a, 2)) / 2)
- ARR(a, 2) = Format(ARR(a, 2), Left(Tmp, Len(Tmp) - 1))
- Next
- [b1].Resize(UBound(ARR), 1) = Application.Index(ARR, , 2)
- End Sub
复制代码
|