怎么把工资表转换成工资条
怎么把工资表转换成工资条 很实用,谢谢! 很实用,谢谢 很實用,不錯 学习中,谢谢分享 不错 用起来很方便 如果可以复制多个工作表就好了回复 楼主 whd123 的帖子
晕,我太菜,怎么没看懂呀,帮帮我. 谢谢分享,学习了. #kt..jcwcn.com@ 有点晕 谢谢共享! 太好了,多谢多谢! 谢谢分享 我看了半天还是不明白请楼主说明白些 用VBA的啊,貌似用OFFSET也可以,不过要拖动,编程相对大部分人来说有点难
谢谢
谢谢 太谢谢了; 我用了怎么不行??? 我用了怎么不行???#my.jcwcm.com@ (^#@^ 为人民服务,非常好 看了半天没懂#@#$#$ 非常好的表 太方便了~我也有个其他的办法 给大家参考
在excel中新建一个文件,将其命名为“工资表与工资条”,在工作表“sheet1”中输入并编辑好本单位职工工资总表(如表1所示)后,点击“工具”菜单→“宏”→“宏…”→输入宏名“生成工资条”→创建,输入如下的宏的各行文本,输入完成后保存该宏。将工作表“sheet1”复制为另一个工作表“sheet2”中,使“sheet2”成为当前工作表,执行刚才创建的宏,即可很快将表1所示的工资表转换为表2所示的工资条。
Sub 生成工资条()
Cells.Select
'选择整个表去掉表格线
Range("F1").Activate
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
Selection.Borders(xlEdgeLeft).LineStyle = xlNone
Selection.Borders(xlEdgeTop).LineStyle = xlNone
Selection.Borders(xlEdgeBottom).LineStyle = xlNone
Selection.Borders(xlEdgeRight).LineStyle = xlNone
Selection.Borders(xlInsideVertical).LineStyle = xlNone
Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
Rows("2:2").Select
'选择第2行
Selection.Insert Shift:=xlDown
'在第2行前插入一行,保持第2行为选中状态
num = 150
'总人数×3,如工资表中有100人则为100×3即num = 300
col = 14
'工资表的栏数,如工资表有17栏则
'col=17
num1 = 4
Do While num1 <= num
'循环插入空行
Range(Cells(num1, 1), Cells(num1, col)).Select
'选中第num1行的第1列到第col列
Selection.Insert Shift:=xlDown
Selection.Insert Shift:=xlDown
num1 = num1 + 3
Loop
Range(Cells(1, 1), Cells(1, col)).Select
Application.CutCopyMode = False
'剪切复制模式无效
Selection.Copy
'复制选择区域
Range("A2").Select
'选择A2单元格
ActiveSheet.Paste
'从A2单元格起粘贴内容
num2 = 5
Do While num2 <= num
'循环插入标题行
Range(Cells(1, 1), Cells(1, col)).Select
Application.CutCopyMode = False
Selection.Copy
Cells(num2, 1).Select
ActiveSheet.Paste
num2 = num2 + 3
Loop
Range(Cells(2, 1), Cells(3, col)).Select
Application.CutCopyMode = False
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
'定义表格边框线、内线样式
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlDouble
.Weight = xlThick
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlDouble
.Weight = xlThick
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlDouble
.Weight = xlThick
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlDouble
.Weight = xlThick
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlInsideVertical)
.LineStyle = xlDash
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlInsideHorizontal)
.LineStyle = xlDash
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
Selection.Copy
Range(Cells(5, 1), Cells(6, col)).Select
Selection.PasteSpecial Paste:=xlFormats, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
'接上行删除上行尾的连字符,复制表格线样式
num3 = 8
Do While num3 <= num
'循环复制表格线样式
Range(Cells(num3, 1), Cells(num3 + 1, col)).Select
Selection.PasteSpecial Paste:=xlFormats, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
num3 = num3 + 3
Loop
Rows("1:1").Select
'删除多余的一行
Selection.Delete
End Sub 谢谢#bbs.jcwcn.com@ meijinbiya 很实用,谢谢! 谢谢呀谢谢呀谢谢呀 谢谢21楼的朋友,是个好办法,向你学习.. jc:cnheart jc:cnheart jc:cnheart 先下载 再学习 请看图! 汗一个,没钱
