|
<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> |
|