工资条代码...
Excel VBA实现工资条打印效果..网上找的一些不好用,让朋友给写的...好简化一下我们人事的工作,记录一下,随用随取...VBA的强悍,不用我多说做这方面的工作流的开发应用等,前途还是"靓靓的",....
Private Sub CopyHead_Click()
endRows_Num = InputBox("请输入工资条结束行:" + Chr(13) + Chr(13) + "输入数字就可以了", "输入")
If endRows_Num = "" Then
End
End If
nrow = 3
For x = 1 To endRows_Num - nrow
Rows("2:2").Select '选择标头行
Selection.Copy '复制
nrow = nrow + 1
Rows(Trim(Str(nrow)) + ":" + Trim(Str(nrow))).Select '选择插入目标行
If Trim(Cells(nrow, 1)) = "工号" Or Trim(Cells(nrow, 1)) = "" Then '检查目标行内容的正确性!
MsgBox ("程序发现目标行的内容不符,请检查后再运行些程序!")
End
End If
Selection.Insert Shift:=xlDown '插入复制行
Application.CutCopyMode = False
Rows(Trim(Str(nrow)) + ":" + Trim(Str(nrow))).Select
Selection.Insert Shift:=xlDown '插入一行空白行
Selection.RowHeight = 5 '空白行的行高
Selection.Borders(xlDiagonalDown).LineStyle = xlNone '把空白行的线条去掉
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
Selection.Borders(xlEdgeLeft).LineStyle = xlNone
Selection.Borders(xlEdgeRight).LineStyle = xlNone
Selection.Borders(xlInsideVertical).LineStyle = xlNone
nrow = nrow + 2
Next
End Sub
![](https://www.cnblogs.com/images/cnblogs_com/wxbbk/sourcefile.jpg)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockEnd.gif)
![](https://www.cnblogs.com/images/cnblogs_com/wxbbk/sourcefile.jpg)
![](https://www.cnblogs.com/images/cnblogs_com/wxbbk/newfile.jpg)