|
先交一份工资发放明细的代码。
- Sub 工资发放明细()
- Dim str As String
- Dim wb As Workbook
- Dim sht, sht1 As Worksheet
- Dim i, n, x, y As Integer
- Dim rng As Range
- str = ThisWorkbook.Path & "" & Year(Now()) & "年" & Month(Now()) - 1 & "月份工资发放明细.xlsx"
- Set wb = GetObject(str)
- Set sht1 = wb.Worksheets(1)
- Set sht = ThisWorkbook.Worksheets(1)
- i = sht.Cells(3, 2).End(xlDown).Row
- x = sht1.Cells(4, 2).End(xlDown).Row
- For n = 3 To i
- For y = 4 To x
- If sht.Cells(n, 2).Value = sht1.Cells(y, 2).Value Then
- If sht.Cells(n, 2).Offset(0, 1).Value = sht1.Cells(y, 2).Offset(0, 1).Value Then
- sht1.Cells(y, 2).Offset(0, 2).Value = sht.Cells(n, 2).Offset(0, 31).Value
- End If
- End If
- Next
- Next
- End Sub
复制代码 |
|