at your own risk.
Dim sh As Worksheet
Dim i&, cnt&, rng As Range, result
With Worksheets("VBASheet")
For i = 1 To .Cells(Rows.Count, "D").End(xlUp).Row
If .Cells(i, "D").Value <> "" Then
On Error Resume Next
Set sh = Worksheets(.Cells(i, "D").Value)
On Error GoTo 0
If Not sh Is Nothing Then
Set rng = sh.UsedRange.Find(what:=.Cells(i, "C").Value, LookIn:=xlValues, Lookat:=xlWhole)
If Not rng Is Nothing Then
result = Application.Match(.Cells(i, "B").Value, sh.Range("1:1"), 0)
If IsNumeric(result) Then
For cnt = result + 1 To sh.Cells(rng.Row, Columns.Count).End(xlToLeft).Column
If Left(sh.Cells(1, cnt), 2) = "KW" Then
sh.Cells(5, cnt) = sh.Cells(2, cnt).Value
End If
Next
End If
End If
End If
End If
Next
End With
|