各位大侠,谁能帮忙解析一下每一个步骤的意思啊,在线急等!!!!
Sub trans() Application.Worksheets.Add After:=Worksheets(Worksheets.Count) Cells(1, 1) = "公司" Cells(1, 2) = "部门" Cells(1, 3) = "月份" Cells(1, 4) = "项目" Cells(1, 5) = "金额" k = Worksheets("Payroll Cost -不含外籍").Range("b65536").End(xlUp).Row n = 1 If k = 1 Then Exit Sub For i = 3 To k For j = 3 To 200 ' If Worksheets("sheet1").Cells(i, j) > 0 Then n = n + 1 Cells(n, 1) = Worksheets("Payroll Cost -不含外籍").Cells(i, 1).Value Cells(n, 2) = Worksheets("Payroll Cost -不含外籍").Cells(i, 2).Value Cells(n, 3) = Worksheets("Payroll Cost -不含外籍").Cells(1, j).Value Cells(n, 4) = Worksheets("Payroll Cost -不含外籍").Cells(2, j).Value Cells(n, 5) = Worksheets("Payroll Cost -不含外籍").Cells(i, j).Value ' End If Next j Next i End Sub
|