Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,124
Default Never-ending For Next Loop

Actually,
to 4 in this case

--
Don Guillett
SalesAid Software

"John Bundy" wrote in message
...
The 2 in the for statement tells where to stop, change to a 3 as in below

for i=cells(rows.count,"a").end(xlup).row to 3 step -1

--
-John
Please rate when your question is answered to help us and others know what
is helpful.


"Helen" wrote:

The first three lines of the table are headings, is there a way to
customise
this code so that it ignores the first 3 rows?

"Don Guillett" wrote:

something like this to delete the rows

for i=cells(rows.count,"a").end(xlup).row to 2 step -1
if len(cells(i,"a"))<3 then rows(i).delete
next i

--
Don Guillett
SalesAid Software

"Helen" wrote in message
...
I want to delete any lines in a spreadsheet where the first column
doesn't
conform to a three character code. This includes blank cells, but
also
strings with more or less characters. The code should start from Row
4.

I came up with the following:

Sheets("Purchase Report").Select
Range("A1").Select

myRows = Selection.CurrentRegion.Rows.Count

Cells(4, 1).Select

For x = 4 To myRows

Cells(x, 1).Select

Company = Sheets("Purchase Report").Cells(x, 1)

If Len(Company) = 3 Then

GoTo PlantNumberOK

Else

Rows(x).Delete

x = x - 1

myRows = myRows - 1

PlantNumberOK:

End If

Next x

Somehow when I run this X can become a higher number than myRows, and
when
it runs out of data it starts to delete the blank cells beneath the
myRows
set. What have I done wrong?





Reply
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
Filenames ending with :1 and :2 djn Excel Discussion (Misc queries) 7 January 14th 10 04:01 PM
ending vba Arnold Klapheck Excel Programming 4 August 29th 06 08:15 PM
Week ending [email protected] Excel Worksheet Functions 3 November 1st 05 04:52 PM
Ending zero RAB Excel Discussion (Misc queries) 3 August 25th 05 06:09 PM
Ending Sub Paul Excel Programming 3 October 1st 04 07:48 PM


All times are GMT +1. The time now is 09:05 PM.

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

About Us

"It's about Microsoft Excel"