how to clear memory stored in the variables?
Would like to reset j,k,m,n,p,q,r back to 0, so that it will start from the
first column again.
--------------
Sub sort_for_case1_test()
d = 0
e = 1
' For c = 0 To 11
Sheets("Datasheet2").Select
Cells.Select
Selection.Sort Key1:=Range("B2"), Order1:=xlAscending,
Key2:=Range("g2").Offset(0, c) _
, Order2:=xlDescending, Key3:=Range("D2"), Order3:=xlAscending,
Header _
:=xlYes, OrderCustom:=1, MatchCase:=False,
Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal, DataOption2:=xlSortNormal, DataOption3:= _
xlSortNormal
j = k = m = n = p = q = r = 0
Do While e < 13
For i = 0 To 2427
If Cells(2, 2).Offset(i, 0).Value = e And Cells(2, 2).Offset(i,
2).Value = 92 Then
Cells(2, 2).Offset(i, 0).Resize(1, 3).Copy _
Destination:=Cells(2, 22).Offset(d, j)
j = j + 4
ElseIf Cells(2, 2).Offset(i, 0).Value = e And Cells(2,
2).Offset(i, 2).Value = 93 Then
Cells(2, 2).Offset(i, 0).Resize(1, 3).Copy _
Destination:=Cells(3, 22).Offset(d, k)
k = k + 4
ElseIf Cells(2, 2).Offset(i, 0).Value = e And Cells(2,
2).Offset(i, 2).Value = 94 Then
Cells(2, 2).Offset(i, 0).Resize(1, 3).Copy _
Destination:=Cells(4, 22).Offset(d, m)
m = m + 4
ElseIf Cells(2, 2).Offset(i, 0).Value = e And Cells(2,
2).Offset(i, 2).Value = 95 Then
Cells(2, 2).Offset(i, 0).Resize(1, 3).Copy _
Destination:=Cells(5, 22).Offset(d, n)
n = n + 4
ElseIf Cells(2, 2).Offset(i, 0).Value = e And Cells(2,
2).Offset(i, 2).Value = 96 Then
Cells(2, 2).Offset(i, 0).Resize(1, 3).Copy _
Destination:=Cells(6, 22).Offset(d, p)
p = p + 4
ElseIf Cells(2, 2).Offset(i, 0).Value = e And Cells(2,
2).Offset(i, 2).Value = 97 Then
Cells(2, 2).Offset(i, 0).Resize(1, 3).Copy _
Destination:=Cells(7, 22).Offset(d, q)
q = q + 4
ElseIf Cells(2, 2).Offset(i, 0).Value = e And Cells(2,
2).Offset(i, 2).Value = 98 Then
Cells(2, 2).Offset(i, 0).Resize(1, 3).Copy _
Destination:=Cells(8, 22).Offset(d, r)
r = r + 4
End If
Next i
d = d + 8
e = e + 1
Loop
' Next c
End Sub
"gocush" wrote:
What is the full code for your loop?
"KiriumF1" wrote:
hi i was doing a loop and and would like to reset it back to i = 0 at the
beginning of each loop. what should i type at the end of each loop to reset
the value? I tried i = 0, but it doesn't work.
|