J
jimmy
I have this piece of code which jouni helped out with.
the code doesnt really do anything because the imbedded
for loop cuts out of the outer for loop and exiting the
macro. it exits out before executing the most important
command. i dont know why....
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
the inner for loop is the one that cuts out, it goes
through properly like its supposed to but then it skips
over the if statement and goes completely out of the outer
for outside the Next ws command. Any ideas why this is
happening?
the code doesnt really do anything because the imbedded
for loop cuts out of the outer for loop and exiting the
macro. it exits out before executing the most important
command. i dont know why....
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
the inner for loop is the one that cuts out, it goes
through properly like its supposed to but then it skips
over the if statement and goes completely out of the outer
for outside the Next ws command. Any ideas why this is
happening?