fork download
  1. Option Explicit
  2.  
  3. Sub 別ブックのすべてのセルを取得5()
  4.  
  5. Dim startTime As Double
  6. Dim middleTime As Double
  7. Dim processTime As Double
  8.  
  9. startTime = Timer '開始時間取得
  10.  
  11. Application.ScreenUpdating = False '画面描画を停止
  12. Application.EnableEvents = False 'イベントを抑止
  13. Application.DisplayAlerts = False '確認メッセージを抑止
  14. Application.Calculation = xlCalculationManual '計算を手動に
  15.  
  16. '------------------------------------------------------------------------ここまで
  17. '↑ここまでは上記サンプルコードと同一↑
  18. 'メイン処理0の時間をイミディエイトウィンドウに出力
  19. middleTime = Timer
  20. processTime = middleTime - startTime
  21. Debug.Print "メイン処理0の終了:"; processTime & "秒" & vbCrLf
  22. 'Call メイン処理0の終了
  23.  
  24. '------------------------------------------------------------------------1ここから
  25. Dim FullPath1 As String, FullPath2 As String, FullPath3 As String, FullPath4 As String
  26. FullPath1 = "C:\Users\名前\Desktop\Excelフォルダ" & "\" & "配信スケジュール .xlsm" ' "救急患者集計.xlsm"
  27. FullPath2 = "C:\Users\名前\Desktop\Excelフォルダ" & "\" & "未納本文.xlsm" ' "救急患者集計.xlsm""未納整理簿.xlsm"
  28. FullPath3 = "C:\Users\名前\Desktop\Excelフォルダ" & "\" & "未納本文.xlsm" ' "救急患者集計.xlsm""未納整理簿.xlsm"
  29. FullPath4 = "C:\Users\名前\Desktop\Excelフォルダ" & "\" & "未納本文.xlsm" ' "救急患者集計.xlsm""未収金折衝状況表.xlsm"
  30.  
  31. FullPath1 = "D:\goo\excel\goo446\配信スケジュール.xlsm"
  32. FullPath2 = "D:\goo\excel\goo446\未納本文.xlsm"
  33. FullPath3 = "D:\goo\excel\goo446\未納本文.xlsm"
  34. FullPath4 = "D:\goo\excel\goo446\未納本文.xlsm"
  35.  
  36. Dim Fullpath As Variant
  37. Dim Frsheet As Variant
  38. Dim ToSheet As Variant
  39. Dim Title As Variant
  40. Dim i As Long
  41. Fullpath = Array(FullPath1, FullPath2, FullPath3, FullPath4)
  42. Frsheet = Array("sheet5", "未納本文", "全部1", "未納本文")
  43. ToSheet = Array("kyu", "nyu", "gai", "折衝取込")
  44. Title = Array("未納本文処理1の終了:", "全部1処理2の終了:", "未納本文処理3の終了:", "全部1をふくめた完了までの所要時間:")
  45. '既存のシート削除
  46. Dim ws As Worksheet
  47. For Each ws In ThisWorkbook.Worksheets
  48. If check_sheet(ws.name, ToSheet) = True Then
  49. ws.Delete
  50. End If
  51. Next
  52. 'シートのコピー
  53. For i = 3 To 0 Step -1
  54. Call copy_sheet(Fullpath(i), Frsheet(i), ToSheet(i))
  55. middleTime = Timer
  56. processTime = middleTime - startTime
  57. Debug.Print Title(i); processTime & "秒" & vbCrLf
  58. Next
  59.  
  60. Application.Calculation = xlCalculationAutomatic '計算を自動に
  61. Application.DisplayAlerts = True '確認メッセージを開始
  62. Application.EnableEvents = True 'イベントを開始
  63. Application.ScreenUpdating = True
  64. MsgBox "書き換えました"
  65. End Sub
  66. Private Function check_sheet(ByVal name As String, ByVal ToSheet As Variant) As Boolean
  67. Dim i As Long
  68. check_sheet = True
  69. For i = 0 To UBound(ToSheet)
  70. If name = ToSheet(i) Then Exit Function
  71. Next
  72. check_sheet = False
  73. End Function
  74.  
  75. Private Sub copy_sheet(ByVal Fullpath As String, ByVal Frsheet As String, ByVal ToSheet As String)
  76. Dim Fwb As Workbook
  77. Set Fwb = Workbooks.Open(Fullpath, ReadOnly:=True) '読取り専用で開く
  78. ActiveWindow.Visible = False
  79. Fwb.Worksheets(Frsheet).Copy Before:=ThisWorkbook.Worksheets(1)
  80. ThisWorkbook.Worksheets(1).name = ToSheet
  81. Fwb.Close
  82. End Sub
  83.  
  84.  
Not running #stdin #stdout 0s 0KB
stdin
Standard input is empty
stdout
Standard output is empty