ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   how to clear memory stored in the variables? (https://www.excelbanter.com/excel-programming/318451-how-clear-memory-stored-variables.html)

KiriumF1

how to clear memory stored in the variables?
 
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.

gocush[_28_]

how to clear memory stored in the variables?
 
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.


KiriumF1

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.


Sharad

how to clear memory stored in the variables?
 
Hi,

j = k = m = n = p = q = r = 0
will not work.
Write seperately for each variable.
j=0
k=0
m=0
and so on.

Sharad

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Bob Phillips[_6_]

how to clear memory stored in the variables?
 
j = 0: k = 0: m = 0: n = 0: p = 0: q = 0: r = 0


--

HTH

RP
(remove nothere from the email address if mailing direct)


"KiriumF1" wrote in message
...
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.




KiriumF1

how to clear memory stored in the variables?
 
thanks!

"Bob Phillips" wrote:

j = 0: k = 0: m = 0: n = 0: p = 0: q = 0: r = 0


--

HTH

RP
(remove nothere from the email address if mailing direct)


"KiriumF1" wrote in message
...
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.





KiriumF1

how to clear memory stored in the variables?
 
thanks!

"Sharad" wrote:

Hi,

j = k = m = n = p = q = r = 0
will not work.
Write seperately for each variable.
j=0
k=0
m=0
and so on.

Sharad

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!



All times are GMT +1. The time now is 07:14 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com