My code has a loop that is finding whether the value of a given column in a pivot table is the min/max of that row. A caveat is certain rows have a characteristic entry repeated, so I have a set of If ElseIf conditions to skip the copying process for these entries. The code is as follows:
For i = 0 To 339
wfr = wfr + CStr(i + 5)
Sheets("ET Pivot").Select
If Sheets("ET Pivot").Range(wfr).Value = 7 Then
GoTo LoopExit
ElseIf Sheets("ET Pivot").Range(wfr).Value = 9 Then
GoTo LoopExit
ElseIf Sheets("ET Pivot").Range(wfr).Value = 99999.99 Then
GoTo LoopExit
ElseIf Sheets("ET Pivot").Range(wfr).Value = 1 Then
GoTo LoopExit
End If
If Sheets("ET Pivot").Range(wfr).Value = Sheets("ET Pivot").Range("AB" + CStr(i + 5)).Value Then
Sheets("ET Pivot").Select
Sheets("ET Pivot").Rows(i + 5 & ":" & i + 5).Select
Selection.Copy
Sheets("ET Outliers").Select
Sheets("ET Outliers").Range("A" + CStr(ic)).Select
ActiveSheet.Paste
Application.CutCopyMode = False
ic = ic + 1
ElseIf Sheets("ET Pivot").Range(wfr).Value = Sheets("ET Pivot").Range("AC" + CStr(i + 5)).Value Then
Sheets("ET Pivot").Select
Sheets("ET Pivot").Rows(i + 5 & ":" & i + 5).Select
Selection.Copy
Sheets("ET Outliers").Select
Sheets("ET Outliers").Range("A" + CStr(ic)).Select
ActiveSheet.Paste
ic = ic + 1
End If
LoopExit:
wfr = wfrc
Next i
The first four If statements are the skip conditions. The conditions 9, 99999.99, and 1 work as planned. For some reason, the 7 condition does not trigger the If statement. I have made sure the cell value is actually 7 and not rounded, I have changed the order of the conditions, and I have added a dummy condition first, all to no avail. I'm not sure why this specific case is not working.
Aucun commentaire:
Enregistrer un commentaire