Excel VBA質問スレ Part7
at TECH
786:y
08/08/12 21:28:33
>>779
Dim r As Long, c As Integer, cc As Integer, dr As Long, dt As Variant, rNum As Long
rNum = WorksheetFunction.CountIf(Range("D:IV"), "<>")
ReDim dt(1 To rNum, 1 To 5)
r = 1: dr = 1
Do While Cells(r, 1) <> ""
If Cells(r, 4) <> "" Then
For c = 1 To 4
dt(dr, c) = Cells(r, c)
Next
dr = dr + 1
ElseIf Cells(r, 5) <> "" Then
c = 5
Do While Cells(r, c) <> ""
For cc = 1 To 4
dt(dr, cc) = Cells(r, cc)
Next
dt(dr, 5) = Cells(r, c)
c = c + 1
dr = dr + 1
Loop
End If
r = r + 1
Loop
With ThisWorkbook.Sheets.Add
.Range(.Cells(1, 1), .Cells(1, 1).Offset(rNum - 1, 4)) = dt
End With
もっと効率的な方法で書ける方もおられると思いますが...
それと、マルチ(複数のスレッドで同じ質問をすること)はしないようにしてくださいね。
次ページ続きを表示1を表示最新レス表示スレッドの検索類似スレ一覧話題のニュースおまかせリスト▼オプションを表示暇つぶし2ch
4710日前に更新/336 KB
担当:undef