Excel精英培训网

 找回密码
 注册
数据透视表40+个常用小技巧,让你一次学会!
查看: 1023|回复: 4

[已解决]求大神帮忙--考勤数据处理

[复制链接]
发表于 2022-8-23 15:03 | 显示全部楼层 |阅读模式
求大神帮忙,想要处理后数据的格式, 用代码或其他方法都可以。




最佳答案
2022-8-23 17:19
本帖最后由 我行我速2008 于 2022-8-23 17:49 编辑

试试看行不行

Sub tt()
    Dim ar, br, cr(1 To 4), r, c, i, x
    Dim sh As Worksheet
    Set sh = Sheet2
    sh.[a1].CurrentRegion.Offset(2, 0).ClearContents
    With Sheet1
        ar = .[a1].CurrentRegion
        For r = 5 To UBound(ar)
            i = .Cells(r, 1).Cells.MergeArea.Count
            For c = 4 To UBound(ar, 2)
                 If Application.CountA(.Cells(r, c).Resize(i, 1)) > 0 Then
                    br = .Cells(r, c).Resize(i, 1)
                    cr(1) = ar(r, 3): cr(2) = ar(r, 2)
                    cr(3) = ar(3, c): cr(4) = ar(4, c)
                    x = sh.Cells(Rows.Count, 1).End(xlUp).Row + 1
                    sh.Cells(x, 1).Resize(1, 4) = cr
                    sh.Cells(x, 5).Resize(1, i) = Application.Transpose(br)
                 End If
            Next c
            r = r + i - 1
        Next r
    End With
    Set sh = Nothing
End Sub

8月18日打卡(1)(1).rar

62.36 KB, 下载次数: 10

表格

excel精英培训的微信平台,每天都会发送excel学习教程和资料。扫一扫明天就可以收到新教程
发表于 2022-8-23 17:19 | 显示全部楼层    本楼为最佳答案   
本帖最后由 我行我速2008 于 2022-8-23 17:49 编辑

试试看行不行

Sub tt()
    Dim ar, br, cr(1 To 4), r, c, i, x
    Dim sh As Worksheet
    Set sh = Sheet2
    sh.[a1].CurrentRegion.Offset(2, 0).ClearContents
    With Sheet1
        ar = .[a1].CurrentRegion
        For r = 5 To UBound(ar)
            i = .Cells(r, 1).Cells.MergeArea.Count
            For c = 4 To UBound(ar, 2)
                 If Application.CountA(.Cells(r, c).Resize(i, 1)) > 0 Then
                    br = .Cells(r, c).Resize(i, 1)
                    cr(1) = ar(r, 3): cr(2) = ar(r, 2)
                    cr(3) = ar(3, c): cr(4) = ar(4, c)
                    x = sh.Cells(Rows.Count, 1).End(xlUp).Row + 1
                    sh.Cells(x, 1).Resize(1, 4) = cr
                    sh.Cells(x, 5).Resize(1, i) = Application.Transpose(br)
                 End If
            Next c
            r = r + i - 1
        Next r
    End With
    Set sh = Nothing
End Sub
回复

使用道具 举报

发表于 2022-8-23 18:16 | 显示全部楼层
本帖最后由 我行我速2008 于 2022-8-23 22:04 编辑

多少邪恶的公司!一天上班多少小时?

8月18日打卡(20220823).zip

149.55 KB, 下载次数: 10

回复

使用道具 举报

 楼主| 发表于 2022-8-24 14:50 | 显示全部楼层
我行我速2008 发表于 2022-8-23 18:16
多少邪恶的公司!一天上班多少小时?

谢谢!现在工厂上班时间都是这样的

回复

使用道具 举报

 楼主| 发表于 2022-8-24 14:51 | 显示全部楼层
我行我速2008 发表于 2022-8-23 17:19
试试看行不行

Sub tt()

可以了, 谢谢大神!
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|Archiver|Excel精英培训 ( 豫ICP备11015029号 )

GMT+8, 2024-4-29 22:27 , Processed in 0.258319 second(s), 10 queries , Gzip On, Yac On.

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表