fork download
  1. Option Explicit
  2. Public Sub 点検案内()
  3. Const Folder = "D:\goo\data8\点検"
  4. Dim sh1 As Worksheet
  5. Dim sh2 As Worksheet
  6. Dim sh3 As Worksheet
  7. Dim ws As Worksheet
  8. Dim maxrow As Long
  9. Dim wrow As Long
  10. Dim wb As Workbook
  11. Dim fname As String
  12. Set sh1 = Worksheets("データ")
  13. Set sh2 = Worksheets("Sheet2")
  14. Set sh3 = Worksheets("Sheet3")
  15. maxrow = sh1.Cells(Rows.Count, 1).End(xlUp).Row '最大行取得
  16. For wrow = 3 To maxrow
  17. If sh1.Cells(wrow, "B").Value = 2 Then
  18. Set ws = sh2
  19. Else
  20. Set ws = sh3
  21. End If
  22. ws.Cells(1, "A").Value = sh1.Cells(wrow, "A").Value '氏名
  23. ws.Cells(4, "A").Value = sh1.Cells(wrow, "C").Value 'A点検日
  24. ws.Cells(4, "B").Value = sh1.Cells(wrow, "D").Value 'A点検時間
  25. If sh1.Cells(wrow, "B").Value = 2 Then
  26. ws.Cells(4, "C").Value = sh1.Cells(wrow, "E").Value 'B点検日
  27. ws.Cells(4, "D").Value = sh1.Cells(wrow, "F").Value 'B点検時間
  28. End If
  29. Set wb = Workbooks.Add
  30. ws.Range("A1:D4").Copy wb.Worksheets("Sheet1").Range("A1")
  31. fname = Folder & "\" & ws.Cells(1, "A") & ".xlsx"
  32. wb.SaveAs (fname)
  33. wb.Close
  34. Next
  35. End Sub
  36.  
Not running #stdin #stdout 0s 0KB
stdin
Standard input is empty
stdout
Standard output is empty