|
学习老师的代码。谢谢老师!
Sub test()
Dim arr, i, j, t, a, b, c, d, e, pos
pos = Sheets("差旅费报销清单").[a1].CurrentRegion.Offset(1).Resize(1).Value
rq = Format(Now, "yymmddhhmmss")
ReDim arr(1 To 10 ^ 3, 1 To UBound(pos, 2))
With Sheets("差旅费报销单")
t = Split(pos(1, 7), "-")
a = Val(Mid(t(0), 2)): b = Val(Mid(t(1), 2))
For j = 2 To UBound(pos, 2)
If InStr(pos(1, j), "-") Then
t = Split(pos(1, j), "-")
c = Val(Mid(t(0), 2)): d = Val(Mid(t(1), 2)): e = Left(t(0), 1)
For i = c To d
arr(i - c + 1, j) = .Range(e & i).Value
Next
Else
For i = a To b
arr(i - a + 1, 1) = rq
arr(i - a + 1, j) = .Range(pos(1, j)).Value
Next
End If
Next
End With
With Sheets("差旅费报销清单")
.Range("b:b, g:g, i:i").NumberFormatLocal = "yyyy-mm-dd"
.Range("A:A").NumberFormatLocal = "000000"
With .Cells(.Cells(Rows.Count, "A").End(xlUp).Row + 1, "a").Resize(b - a + 1, UBound(arr, 2))
.Borders.LineStyle = xlContinuous
.Value = arr
End With
End With
End Sub
|
评分
-
1
查看全部评分
-
|