|
今晩は。
良かったら参考にして下さい。バグがあるかも知れないので、いろいろテストして見て
下さい。
Option Explicit
Option Base 1
Dim sinki As Object
Dim vv As Variant
Public Sub db()
Dim i As Integer, ir As Integer, ic As Integer
ir = 1: ic = 1
Dim b As Boolean
vv = ThisWorkbook.Worksheets("DBシート").Range("a1").CurrentRegion.Value
Workbooks.Add
Set sinki = ActiveWorkbook
Cells(1, 1).Value = vv(1, 1)
Cells(1, 2).Value = vv(1, 2)
For i = 2 To UBound(vv, 1)
If vv(i, 1) <> Cells(ir, 1) Or vv(i, 2) <> Cells(ir, 2) Then
ir = ir + 1
Cells(ir, 1).Value = vv(i, 1)
Cells(ir, 2).Value = vv(i, 2)
End If
b = False: ic = 3
Do While Cells(1, ic).Value <> ""
If Cells(1, ic).Value = vv(i, 5) Then
b = True
Exit Do
End If
ic = ic + 1
Loop
If b = False Then Cells(1, ic).Value = vv(i, 5)
Cells(ir, ic).Value = Cells(ir, ic).Value + 1
Next
End Sub
|
|