Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

For...Next

Status
Not open for further replies.

User4Fun

Programmer
Aug 6, 2008
15
0
0
US
I am having nightmares
This is suppose to satrt at last row
if the value in that row (intFound) is bigger than or equal to intFirstNum
and if the same value is smaller than or equal intSecond

Then leave it alone and go one row up, otherwise
delete that current row.
PLEASE HELP
Code:
intRow = 44
    For intRow = intLastRow To intRow Step -1
      intFound = Cells(intLastRow, intCol).Value
         
         If intFound >= intFirstNum Then
                       If intFound <= intSecondNum Then
                            intLastRow = intLastRow - 1
                       Else
                                                        
                            Sheets("ACUITY Vs ISTEP GRAPH").Rows(intLastRow).Delete xlShiftUp
                       End If
         Else
               Sheets("ACUITY Vs ISTEP GRAPH").Rows(intLastRow).Delete xlShiftUp
         End If
         Next intRow
 



Code:
Sheets("ACUITY Vs ISTEP GRAPH").Rows([b]intRow[/b]).Delete xlShiftUp

Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
For intRow = intLastRow To 44 Step -1
intFound = Cells(intRow, intCol).Value
If intFound < intFirstNum Or intFound > intSecondNum Then
Sheets("ACUITY Vs ISTEP GRAPH").Rows(intRow).Delete xlShiftUp
End If
Next intRow

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
'intRow = 44 this changes each loop - don't set it here
intFirstRow =1 '?
intLastRow=44 'these are all guesses
intCol=1 '?

For intRow = intLastRow To intFirstRow Step -1
intFound = Cells(intRow, intCol).Value

'now intFound will change each loop
'only fixed to here there are more errors below
'use skip's method for the rest of the problem and spend
'more time experimenting with for-next loops, and
'nested if-thens, they're meat and potatoes...
'use stop or breakpoints, to examine the contents of variables
'& F8 to slow step thru variables

If intFound >= intFirstNum Then
If intFound <= intSecondNum Then
intLastRow = intLastRow - 1

'I think you want to bump intRow here, not intLastRow

Else

Sheets("ACUITY Vs ISTEP GRAPH").Rows(intRow).Delete xlShiftUp
End If
Else
Sheets("ACUITY Vs ISTEP GRAPH").Rows(intRow).Delete xlShiftUp
End If
Next intRow


John
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top