|
▼kaze11 さん:
ヒントのほうがよかったかもしれませんが、書いてしまったので。
Sheet1にある元データを 、Sheet2に転記します。
Sub Sample()
Dim v1 As Variant
Dim v2() As Variant
Dim z As Long
Dim i As Long
Dim j As Long
Dim cYYMM As String
Dim nYYMM As String
Dim ok As Boolean
v1 = Sheets("Sheet1").UsedRange.Value
ReDim v2(1 To UBound(v1, 1), 1 To UBound(v1, 2))
For i = LBound(v1, 1) To UBound(v1, 1)
ok = True
If i <> LBound(v1, 1) And i <> UBound(v1, 1) Then
cYYMM = Format(v1(i, 1), "yyyymm")
nYYMM = Format(v1(i + 1, 1), "yyyymm")
If cYYMM = nYYMM Then ok = False
End If
If ok Then
z = z + 1
For j = LBound(v1, 2) To UBound(v1, 2)
v2(z, j) = v1(i, j)
Next
End If
Next
Worksheets("Sheet2").Range("A1").Resize(UBound(v2, 1), UBound(v2, 2)).Value = v2
End Sub
|
|