回答編集履歴

1

追加

2020/08/20 07:12

投稿

radames1000
radames1000

スコア1923

test CHANGED
@@ -67,3 +67,91 @@
67
67
  End Sub
68
68
 
69
69
  ```
70
+
71
+ ---
72
+
73
+ こんな感じでしょうか。
74
+
75
+ ```VBA
76
+
77
+ Sub rireki2()
78
+
79
+
80
+
81
+ Sheets("履歴表").Select
82
+
83
+
84
+
85
+ '貼り付け開始行を取得
86
+
87
+ Dim startRow As Long
88
+
89
+ startRow = Cells(Rows.Count, 1).End(xlUp).Row + 1
90
+
91
+
92
+
93
+ '発注書の内容をコピー
94
+
95
+ Sheets("入力").Range("A5:D8").Copy
96
+
97
+ Cells(startRow, 5).PasteSpecial xlPasteValues
98
+
99
+
100
+
101
+ '最終行の取得
102
+
103
+ Dim maxRow As Long, cntRow As Long
104
+
105
+ maxRow = Cells(Rows.Count, 6).End(xlUp).Row + 1
106
+
107
+ Do Until cntRow > 0
108
+
109
+ maxRow = maxRow - 1
110
+
111
+ cntRow = WorksheetFunction.Count(Range(Cells(maxRow, 1), Cells(maxRow, 8)))
112
+
113
+ Loop
114
+
115
+
116
+
117
+ '貼り付け行数の取得
118
+
119
+ Dim psRow As Long
120
+
121
+ psRow = maxRow - startRow + 1
122
+
123
+
124
+
125
+ '発注書の内容をコピー
126
+
127
+ Sheets("入力").Range("A2:D2").Copy
128
+
129
+ Range(Cells(startRow, 1), Cells(maxRow, 1)).PasteSpecial Paste:=xlPasteValues
130
+
131
+
132
+
133
+ 'メーカーの空欄をうめる
134
+
135
+ Dim rng As Range
136
+
137
+ For Each rng In Range(Cells(startRow, 5), Cells(maxRow, 5))
138
+
139
+ If rng.Value = "" Then
140
+
141
+ rng.Value = rng.Offset(-1).Value
142
+
143
+ End If
144
+
145
+ Next
146
+
147
+
148
+
149
+ '貼り付け開始行を選択する※無くても問題ないです
150
+
151
+ Cells(startRow, 1).Select
152
+
153
+
154
+
155
+ End Sub
156
+
157
+ ```