LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 36
Default Help with a loop

that was it...thank you very much
-----Original Message-----
Okay, try this

Dim RowNdx1 As Long
Dim LastRow1 As Long
Sheets("TEST").Select

For RowNdx1 = 384 To 258 Step -1
With Cells(RowNdx1, "C")
If .Value < 1.5 Then
Rows(RowNdx1).Delete
End If
End With
Next RowNdx1

For RowNdx1 = 256 To 130 Step -1
With Cells(RowNdx1, "C")
If .Value < 1.25 Then
Rows(RowNdx1).Delete
End If
End With
Next RowNdx1

For RowNdx1 = 128 To 2 Step -1
With Cells(RowNdx1, "C")
If .Value < 1 Then
Rows(RowNdx1).Delete
End If
End With
Next RowNdx1

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Peter" wrote in

message
...
Sorry Bob, guess I didn't think it all the way through :

(

yes the rows will be fixed.

Thanks for your reply
-----Original Message-----
That is nothing like what you asked for<g

Is the 2-128, 130-256, and 258-384 fixed rows, or

could
they vary.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the

Purbecks
(remove nothere from the email address if mailing

direct)

"Peter" wrote in

message
...
That worked Bob, thank you for the reply but I guess
that's not what I wanted it to do. Here is what I

have:

I have a 3 lists of data in the same columns. The

first
list is in rows 2-128, the second in rows 130-256,

and
the
third in rows 258-384. I would like to delete all

rows
between 2 & 128 that do not contain a 1 in column C,
delete all rows between 130 & 256 that do not contain

1.25
in column C, and delete all rows between 258 & 384

that
do
not contain 1.5 in column C.

Any advice on this?
-----Original Message-----

Dim RowNdx1 As Long
Dim LastRow1 As Long
Sheets("TEST").Select
For RowNdx1 = 128 To 2 Step -1
With Cells(RowNdx1, "C")
If .Value < 1 Then
Rows(RowNdx1).Delete
End If
End With
Next RowNdx1

--

HTH

Bob Phillips
... looking out across Poole Harbour to the

Purbecks
(remove nothere from the email address if mailing

direct)

"Peter" wrote

in
message
...
I am using the following code to delete all rows

that do
not contain a 1 in column C. It works on ALL rows

in
a
worksheet. I need it to only work within a

selection
(A2:H128). I can't seem to get anything to work.

Any
suggestions? TIA

Dim RowNdx1 As Long
Dim LastRow1 As Long
Sheets("TEST").Select
LastRow1 = ActiveSheet.Cells

(Rows.Count, "C").End
(xlUp).Row
For RowNdx1 = LastRow1 To 2 Step -1
With Cells(RowNdx1, "C")
If .Value < 1 Then
Rows(RowNdx1).Delete
End If
End With
Next RowNdx1


.



.



.

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Loop Christina Excel Discussion (Misc queries) 0 March 17th 10 08:55 PM
Find loop doesn't loop JSnow Excel Discussion (Misc queries) 2 June 24th 09 08:28 PM
Worksheet_Change - loop within a loop bgm Excel Programming 1 January 19th 04 01:27 PM
need a loop DENISE Excel Programming 2 January 9th 04 07:58 AM
HELP!!!! Can't stop a loop (NOT an infinite loop) TBA[_2_] Excel Programming 3 December 14th 03 03:33 PM


All times are GMT +1. The time now is 09:55 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"