LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 135
Default for loop exiting out early

It runs the If statement for me. Sounds like "intCounter" is not getting
1 for you.

HTH, Shockley



"jimmy" wrote in message
...
I have the following piece of code that contains 1 for
loop with two imbedded for loops in it. The problem i am
having is that the deepest for loop (ws2) when finishing
breaks out of both outer for loops (r, ws) and exits to
the end. I am not understanding why. the program doesnt
even run through to the if statement (intCounter), just
breaks when for loop (ws2) completes. Any suggestions....

For Each ws In ActiveWorkbook.Sheets
ws.Activate
If Selection.Rows.Count 1 Then
Set Rng = Selection
Else
Set Rng = ActiveSheet.UsedRange.Rows
End If


For r = Rng.Rows.Count To 1 Step -1
V = Rng.Cells(r, 1).Value
intCounter = 0

For Each ws2 In ActiveWorkbook.Sheets
intCounter = intCounter +
Application.WorksheetFunction.CountIf(ws2.Columns( 1), V)
Next ws2

If intCounter 1 Then
Rng.Rows(r).EntireRow.Delete
N = N + 1
End If

Next r


Next ws



 
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
formula help - avtive early j5b9721 Excel Worksheet Functions 0 August 28th 09 04:42 AM
15 minutes early Glenn_H Excel Discussion (Misc queries) 4 January 31st 08 06:44 PM
Early Login, Last Logout junoon Excel Worksheet Functions 3 May 9th 07 04:04 PM
Follow up For loop exiting out early jimmy[_2_] Excel Programming 1 September 26th 03 02:20 AM
Loop ends early BrianB Excel Programming 0 August 15th 03 12:13 PM


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

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"