|
▼K・Y さん:
じゃぁこれで。
Sub Sample2()
Dim sh As Worksheet
Dim v() As String
Dim i As Long
Dim k As Long
Dim s As String
Dim x As Long
Dim c As Range
Dim z As Long
Application.ScreenUpdating = False
Set sh = Workbooks("タスク.xls").Sheets("Sheet1")
x = sh.Range("A" & sh.Rows.Count).End(xlUp).Row
With Workbooks("課題.xls").Sheets("Sheet1")
With .UsedRange
z = .Cells(.Cells.Count).Row
End With
For Each c In .Range("A1:A" & z)
ReDim v(1 To 3)
k = 0
For i = 1 To 3 'A列〜C列
s = c.Offset(, i - 1).Value
If Len(s) > 0 Then
k = k + 1
v(k) = s
End If
Next
x = x + 1
If k > 0 Then
ReDim Preserve v(1 To k)
sh.Cells(x, "A").Value = "依" & Join(v, "-")
End If
sh.Cells(x, "C").Value = "依頼" & Format(Val(.Cells(x, "L")), "00000")
sh.Cells(x, "K").Value = .Cells(x, "Y").Value
Next
End With
sh.Parent.Activate
sh.Select
Set sh = Nothing
Application.ScreenUpdating = True
MsgBox "転記終了しました"
End Sub
|
|