|
- Sub Macro1()
-
- Dim Datasource
- Dim i, n, m, col As Integer
- Sheets("工资条").Select
- Cells.Clear
- Sheets("工资表").Select
- Set Datasource = Application.InputBox(prompt:="请选择要生成工资条的区域:", Type:=8)
-
- Application.ScreenUpdating = False
-
- col = Datasource.Columns.Count
- AddressAll = Datasource.Address
-
- ActiveWorkbook.ActiveSheet.Range(AddressAll).Select
- Selection.Copy
-
- Sheets("工资条").Select
- Range("A1").Select
- ActiveSheet.Paste
-
- n = ActiveSheet.Range("A65535").End(xlUp).Row
- For i = n To 3 Step -1
- ActiveCell.Rows("1:1").EntireRow.Select
- Selection.Copy
- ActiveSheet.Rows(i & ":" & i).EntireRow.Select
- Selection.Insert Shift:=xlDown
- Next i
- n = ActiveSheet.Range("A65535").End(xlUp).Row
- For i = n To 2 Step -2
- ActiveSheet.Rows(i - 1 & ":" & i).EntireRow.Select
- Selection.Insert Shift:=xlDown
- Selection.ClearFormats
- Next i
- n = ActiveSheet.Range("A65535").End(xlUp).Row
- For i = 1 To n / 4
- ActiveSheet.Range(Cells(i * 4 - 1, 1), Cells(i * 4, col)).Select
- With Selection.Borders(xlEdgeLeft)
- .LineStyle = xlContinuous
- .Weight = xlMedium
- End With
- With Selection.Borders(xlEdgeTop)
- .LineStyle = xlContinuous
- .Weight = xlMedium
- End With
- With Selection.Borders(xlEdgeBottom)
- .LineStyle = xlContinuous
- .Weight = xlMedium
- End With
- With Selection.Borders(xlEdgeRight)
- .LineStyle = xlContinuous
- .Weight = xlMedium
- End With
- With Selection.Borders(xlInsideVertical)
- .LineStyle = xlDash
- .Weight = xlThin
- End With
- With Selection.Borders(xlInsideHorizontal)
- .LineStyle = xlDash
- .Weight = xlThin
- End With
- Next i
- ActiveSheet.Rows("1:1").Delete
- Application.ScreenUpdating = True
- End Sub
复制代码 后面大部分代码是设置虚线格式的 |
|