|
アクティブシートの IT:IV列 を作業列として使います。
結果は変数 RetSt に格納されます。イミディエイトウィンドゥへ出力しますから
確認して下さい。なお、作業列の処理状態を見たい場合は、予め
>.CurrentRegion.ClearContents
の行頭に "'" を付けてコメント化して下さい。
Sub Check_Data()
Dim Ary As Variant, Ary2 As Variant
Dim i As Long, Num As Single
Dim C As Range
Dim V As String, MyS As String, RetSt As String
Const CkSt As String = _
"N20,(Z-2.4),N20,(Z-5),N30,(Z-2.4),N20,(Z-3.5),N30,(Z-5)"
Application.ScreenUpdating = False
Range("IT1:IU1").Value = Array("Data1", "Data2")
Ary = Split(CkSt, ")")
For i = 0 To UBound(Ary) - 1
V = CStr(Ary(i)): Ary2 = Split(V, "-")
MyS = Ary2(0)
Num = Val(Ary2(1))
If Left$(MyS, 1) = "," Then
MyS = Right$(MyS, Len(MyS) - 1)
End If
Cells(i + 2, 254).Value = MyS
Cells(i + 2, 255).Value = WorksheetFunction.Round(Num, 1)
Erase Ary2
Next i
Range("IT:IU").Sort Key1:=Range("IT1"), Order1:=xlAscending, _
Key2:=Range("IU1"), Order2:=xlDescending, Header:=xlYes, _
Orientation:=xlSortColumns
With Range("IU2", Range("IU65536").End(xlUp)).Offset(, 1)
.Formula = "=IF($IT1<>$IT2,$IU2)"
For Each C In .SpecialCells(3, 1)
RetSt = RetSt & C.Offset(, -2).Value & "-" & _
C.Offset(, -1).Value & "),"
Next
.CurrentRegion.ClearContents
End With
RetSt = Left$(RetSt, Len(RetSt) - 1)
Application.ScreenUpdating = True
Debug.Print RetSt
End Sub
|
|