|
▼藁にもすがりたい者 さん:
B列が店名なのか数値なのかの判断が必要ですが、店名は【文字列】、それ以外は数値という決めつけです。
Sub Test()
Dim r As Range
Dim a As Range
Dim d As Range
Dim i As Long
Dim dic As Object
Dim nm As String
Dim pos As Range
Set dic = CreateObject("Scripting.Dictionary")
With Sheets("Sheet1")
Set r = .Range("B6", .Range("B" & Rows.Count).End(xlUp)).SpecialCells(xlCellTypeConstants, xlNumbers)
For Each a In r.Areas
Set d = a.Offset(-1).Resize(a.Rows.Count + 1)
nm = d(1).Value '店名
If Not dic.exists(nm) Then '初めて出現?
dic(nm) = True
If Not IsObject(Evaluate(nm & "!A1")) Then 'シート無し?
Worksheets.Add(After:=Worksheets(Worksheets.Count)).Name = nm
End If
With Sheets(nm)
.Cells.ClearContents
Set pos = .Range("A1")
End With
End If
d.EntireRow.Copy pos
Set pos = pos.Offset(d.Rows.Count)
Next
End With
End Sub
|
|