| |
▼nonoka さん:
とりあえず「1つめ」を。
★要件が、以前のものとまったく異なるテーマですから、いったん解決でクローズして
トピをわけられたほうがいいのでは?
フンドシ状態で、トピをあけるのにも苦労しますので。
Schedule側で重複があればあと勝ち、Process側で重複あればSchedule側、上書き
という仕様にしています。
Sub ひとつ目()
Const fCode As String = "D" 'Processシートのコード列
Const fLine As Long = 5 ' データ開始行
Const tCode As String = "H" 'Scheduleシートのコード列
Const tLine As Long = 10 ' データ開始行
Dim dic As Object
Dim c As Range
Dim x As Long
Dim v As Variant
Dim i As Long
Dim j As Long
Dim shTo As Worksheet
Set shTo = Sheets("Schedule")
Set dic = CreateObject("Scripting.Dictionary")
x = shTo.Range(tCode & shTo.Rows.Count).End(xlUp).Row
v = shTo.Range("AD" & tLine & ":AQ" & x).Formula
For Each c In Range(shTo.Range(tCode & tLine), shTo.Range(tCode & x))
dic(c.Value) = c.Row - tLine + 1
Next
With Sheets("Process")
For Each c In Range(.Range(fCode & fLine), .Range(fCode & .Rows.Count).End(xlUp))
If dic.exists(c.Value) Then
i = dic(c.Value)
For j = 1 To UBound(v, 2)
v(i, j) = c.EntireRow.Range("E1").Offset(, j - 1).Value
Next
End If
Next
End With
shTo.Range("AD" & tLine).Resize(UBound(v, 1), UBound(v, 2)).Value = v
shTo.Select
MsgBox "転記完了"
End Sub
|
|