xman2000
04-22-2017, 11:52 AM
Array Relative Erase Variables but Next
Hi Parters,
I have 2columns A:B and in ColumnB i have the values to compare in loop.
i have a array in loop that filter values of ColumnB and return relative array.
but in next loop gives error.
error with preserve old of looping or error with retur blank results.
i think i need erase old value and continues Looping ForNext value.
Please, i need values of array relative to next loop.
if i make For 4 to 4 or For 5 to 5 runs ok.
if i make For 4 to 5 - First Loop (4) ok, but next loop (5) not.
''======================================
example PseudoCode:
For 4 to 5
If c.Value = ValorLvalue Then StudentMarks(n) = c.Row
next
1oLoop
StudentMarks(1) ''=row
StudentMarks(2) ''=row
2oLoop
StudentMarks(1) ''=row
StudentMarks(2) ''=row
''======================================
Sample workbook file atacched
18998
Thank you very much!
Dim ValorLvalue As Long
For ValorLvalue = 4 To 5
Dim Rng As Range, c As Range
Dim StudentMarks()
Dim n As Long
ReDim StudentMarks(1 To ColunaY.Count) ''XMAN2000 MUDAR DEPOIS PARA COLUNAY.COUNT
For Each c In ColunaY
If c.Value = ValorLvalue Then
n = n + 1
StudentMarks(n) = c.Row
End If
Next c
''========================================================
Dim FirstCelYiABSOLUTA As Range
Dim SecondCelYiABSOLUTA As Range
Set FirstCelYiABSOLUTA = WayPts.Cells(ColunaY.Row, "B")
Set SecondCelYiABSOLUTA = WayPts.Cells(ColunaY.Row + 1, "B")
Dim FirstCelXiABSOLUTA As Range
Dim SecondCelXiABSOLUTA As Range
Set FirstCelXiABSOLUTA = WayPts.Cells(ColunaX.Row, "A")
Set SecondCelXiABSOLUTA = WayPts.Cells(ColunaX.Row + 1, "A")
''========================================================
MsgBox "ValorLvalue " & ValorLvalue
MsgBox "FirstCelYiABSOLUTA " & FirstCelYiABSOLUTA
MsgBox "SecondCelYiABSOLUTA " & SecondCelYiABSOLUTA
MsgBox "StudentMarks1 " & StudentMarks(1) ''PROBLEM I NEED VALUE OF VALORLVALUE(5)
MsgBox "StudentMarks2 " & StudentMarks(2) ''PROBLEM I NEED VALUE OF VALORLVALUE(5)
Erase StudentMarks
Next ValorLvalue
End Sub
edit: i put an "Erase StudentMarks" above "Next" in final of code but not working!
Hi Parters,
I have 2columns A:B and in ColumnB i have the values to compare in loop.
i have a array in loop that filter values of ColumnB and return relative array.
but in next loop gives error.
error with preserve old of looping or error with retur blank results.
i think i need erase old value and continues Looping ForNext value.
Please, i need values of array relative to next loop.
if i make For 4 to 4 or For 5 to 5 runs ok.
if i make For 4 to 5 - First Loop (4) ok, but next loop (5) not.
''======================================
example PseudoCode:
For 4 to 5
If c.Value = ValorLvalue Then StudentMarks(n) = c.Row
next
1oLoop
StudentMarks(1) ''=row
StudentMarks(2) ''=row
2oLoop
StudentMarks(1) ''=row
StudentMarks(2) ''=row
''======================================
Sample workbook file atacched
18998
Thank you very much!
Dim ValorLvalue As Long
For ValorLvalue = 4 To 5
Dim Rng As Range, c As Range
Dim StudentMarks()
Dim n As Long
ReDim StudentMarks(1 To ColunaY.Count) ''XMAN2000 MUDAR DEPOIS PARA COLUNAY.COUNT
For Each c In ColunaY
If c.Value = ValorLvalue Then
n = n + 1
StudentMarks(n) = c.Row
End If
Next c
''========================================================
Dim FirstCelYiABSOLUTA As Range
Dim SecondCelYiABSOLUTA As Range
Set FirstCelYiABSOLUTA = WayPts.Cells(ColunaY.Row, "B")
Set SecondCelYiABSOLUTA = WayPts.Cells(ColunaY.Row + 1, "B")
Dim FirstCelXiABSOLUTA As Range
Dim SecondCelXiABSOLUTA As Range
Set FirstCelXiABSOLUTA = WayPts.Cells(ColunaX.Row, "A")
Set SecondCelXiABSOLUTA = WayPts.Cells(ColunaX.Row + 1, "A")
''========================================================
MsgBox "ValorLvalue " & ValorLvalue
MsgBox "FirstCelYiABSOLUTA " & FirstCelYiABSOLUTA
MsgBox "SecondCelYiABSOLUTA " & SecondCelYiABSOLUTA
MsgBox "StudentMarks1 " & StudentMarks(1) ''PROBLEM I NEED VALUE OF VALORLVALUE(5)
MsgBox "StudentMarks2 " & StudentMarks(2) ''PROBLEM I NEED VALUE OF VALORLVALUE(5)
Erase StudentMarks
Next ValorLvalue
End Sub
edit: i put an "Erase StudentMarks" above "Next" in final of code but not working!