VB.net 2010 视频教程 VB.net 2010 视频教程 python基础视频教程
SQL Server 2008 视频教程 c#入门经典教程 Visual Basic从门到精通视频教程
当前位置:
首页 > 编程开发 > vb >
  • excel vba教程之列数据转换成行数据

1.  列数据转换成行数据 by:狼版主

‘原始统计数据.xls
‘http://club.excelhome.net/dispbbs.asp?boardid=2&id=292081&star=1#1166135
Sub Macro1()
Dim i As Long, j As Long, arr, brr, temp, n As Long, k As Long
arr = Sheets("原始考勤数据").[a1].CurrentRegion
ReDim brr(1 To UBound(arr), 1 To 20)
For i = 1 To UBound(arr)
    If arr(i, 3) <> temp Then
        n = n + 1
        k = 0
        For k = 1 To 4
            brr(n, k) = arr(i, k)
        Next
        temp = arr(i, 3)
    Else
        brr(n, k) = arr(i, 4)
        k = k + 1
    End If
Next
Sheets("Sheet1").[a1].Resize(n, 20) = brr
Sheets("Sheet1").[D:T].NumberFormat = "h:mm;@"
End Sub

相关教程