ExcelHome技术论坛

 找回密码
 免费注册

QQ登录

只需一步,快速开始

快捷登录

搜索
EH技术汇-专业的职场技能充电站 妙哉!函数段子手趣味讲函数 Excel服务器-会Excel,做管理系统 Excel Home精品图文教程库
HR薪酬管理数字化实战 Excel 2021函数公式学习大典 Excel数据透视表实战秘技 打造核心竞争力的职场宝典
300集Office 2010微视频教程 数据工作者的案头书 免费直播课集锦 ExcelHome出品 - VBA代码宝免费下载
用ChatGPT与VBA一键搞定Excel WPS表格从入门到精通 Excel VBA经典代码实践指南
查看: 1413|回复: 1

[原创] 工资表讨论,方法之一,请一快讨论

[复制链接]

TA的精华主题

TA的得分主题

发表于 2008-12-12 11:06 | 显示全部楼层 |阅读模式
<b>工资表讨论</b>
<b>代码如下:</b>
<code>''工资单的讨论 NYAFULLEE(LHJ)

Public Sub googZIdang()

''''确定工资单样式
    Dim i As Variant, t As Integer
here:
    i = InputBox("请输入一个数字" & Chr(13) + Chr(10) & "这个数字表示每组的行数" & "必须大于1", "这是标题")
    If IsNumeric(i) And CInt(i) > 1 Then
    Else
    GoTo here:
    End If
    t = Int(i)
   
    '''数据初始化
    Dim row_head As Integer, row_end As Integer, count As Integer, row_numbers As Integer
    Dim col_head As Integer, col_end As Integer
    With Application.ActiveSheet
        row_head = .UsedRange.Row
        row_numbers = .UsedRange.Rows.count
        row_end = .UsedRange.Row + row_numbers - 1
        col_head = .UsedRange.Column
        col_end = .UsedRange.Columns.count + col_head - 1
    End With
   
'''主程序代码
   
    Dim c As Integer, m As Integer
    c = Int((row_numbers - 1) / (t - 1))
    Application.ScreenUpdating = False
    With Range(Cells(row_head, col_head), Cells(row_head, col_end))
   
        ''确定循环次数
        If ((row_numbers - 1) Mod (t - 1)) = 0 Then
        m = c - 1
        Else
        m = c
        End If
        
        ''循环实现工资单
        For count = 1 To m
            Rows(row_head + t + (t + 1) * (count - 1) & ":" & row_head + t + 1 + (t + 1) * (count - 1)).Insert shift:=xlDown
            .Copy Cells(row_head + t + 1 + (t + 1) * (count - 1), col_head)
        Next
    End With
    Application.ScreenUpdating = True
End Sub

Sub restore()
    Dim rng As Range
    Set rng = Sheet2.Range("a1:e13")
    Application.ScreenUpdating = False
    Cells.Clear
    rng.Copy Range("b2:f14")
    Application.ScreenUpdating = True
End Sub
</code>
<b>程序实现见如下图片</b>
01.jpg
02.jpg
03.jpg
04.jpg
05.jpg
06.jpg

工资单.rar

10.92 KB, 下载次数: 18

这是源文件

TA的精华主题

TA的得分主题

 楼主| 发表于 2008-12-15 09:48 | 显示全部楼层
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件       ★免费下载 ★       ★ 使用帮助

改进工资单

用一个按钮实现全部功能
01.jpg
02.jpg
03.jpg

改进工资单.rar

11.1 KB, 下载次数: 15

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

本版积分规则

手机版|关于我们|联系我们|ExcelHome

GMT+8, 2024-6-3 00:56 , Processed in 0.031350 second(s), 12 queries , Gzip On, MemCache On.

Powered by Discuz! X3.4

© 1999-2023 Wooffice Inc.

沪公网安备 31011702000001号 沪ICP备11019229号-2

本论坛言论纯属发表者个人意见,任何违反国家相关法律的言论,本站将协助国家相关部门追究发言者责任!     本站特聘法律顾问:李志群律师

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