|
▼T-K さん:
>Dictionaryを使ってのコード提示ありがとうございます。
どちらかというと配列のコードのつもりだったのですが…
Sub test3()
Dim fSh As Worksheet
Dim tSh As Worksheet
Dim tbl As Range
Dim i As Long, k As Long
Dim dt As Double
Dim com As String
Dim mX, mY
Dim w
Dim flg As Boolean
Set fSh = Sheets("Sheet1")
Set tSh = Sheets("Sheet2")
fSh.Cells.Interior.ColorIndex = xlNone
Set tbl = tSh.Range("A1").CurrentRegion
w = tbl.Value
With fSh.Range("A1").CurrentRegion
For i = 2 To .Rows.Count
com = .Cells(i, "B").Value
mY = Application.Match(com, tbl.Columns("B"), 0)
If IsError(mY) Then
.Rows(i).Interior.ColorIndex = 3
Else
For k = 3 To .Columns.Count
dt = .Cells(1, k).Value2
mX = Application.Match(dt, tbl.Rows(1), 0)
If IsError(mX) Then
If Not flg Then .Columns(k).Interior.ColorIndex = 3
Else
w(mY, mX) = .Cells(i, k).Value
End If
Next
flg = True
End If
Next
End With
tbl.Value = w
End Sub
|
|