I
I hope somebody can help me with my code.<?xml:namespace prefix = o ns = "urn:schemas-microsoft-comfficeffice" /><o></o>
Idea is very simple: I have two columns of data to compare. It is montly results of some measurement. <o></o>
I need to find out non-logical results and with all corresponding combinations, e.g. in column E (were results from month ago) and in column F (were results from current month).
Non-logical results are all combinations in the way that results from one month do not follow results in the current month.
Correct, logical results for measurement results should be:
in month before is positive, and in current month is positive
in month before is negative, and in current month is negative
My code is as follows:
Sub SearchForProblemThenExit()
'Page 112
FinalRow = Cells(Rows.Count, 1).End(xlUp).Row
ProblemFound = False
For i = 2 To FinalRow
If Cells(i, 5).Value < 0 Then
If Cells(i, 6).Value > 0 Then
Cells(i, 8).Value = "Service Revenue"
Cells(i, 1).Resize(1, 8).Interior.ColorIndex = 4
Exit For
End If
End If
Next i
For i = 2 To FinalRow
If Cells(i, 5).Value > 0 Then
If Cells(i, 6).Value < 0 Then
Cells(i, 8).Value = "Service Revenue"
Cells(i, 1).Resize(1, 8).Interior.ColorIndex = 4
Exit For
End If
End If
Next i
For i = 2 To FinalRow
If Cells(i, 5).Value = 0 Then
If Cells(i, 6).Value < 0 Then
Cells(i, 8).Value = "Service Revenue"
Cells(i, 1).Resize(1, 8).Interior.ColorIndex = 4
Exit For
End If
End If
Next i
For i = 2 To FinalRow
If Cells(i, 5).Value = 0 Then
If Cells(i, 6).Value > 0 Then
Cells(i, 8).Value = "Service Revenue"
Cells(i, 1).Resize(1, 8).Interior.ColorIndex = 4
Exit For
End If
End If
Next i
For i = 2 To FinalRow
If Cells(i, 5).Value < 0 Then
If Cells(i, 6).Value = 0 Then
Cells(i, 8).Value = "Service Revenue"
Cells(i, 1).Resize(1, 8).Interior.ColorIndex = 4
Exit For
End If
End If
Next i
For i = 2 To FinalRow
If Cells(i, 5).Value > 0 Then
If Cells(i, 6).Value = 0 Then
Cells(i, 8).Value = "Service Revenue"
Cells(i, 1).Resize(1, 8).Interior.ColorIndex = 4
Exit For
End If
End If
Next i
End Sub
Credits for original code going to the book VBA & Macros: Microsoft Excel 2010, Chapter 5 - Looping
My main problem is, after i rewrite original code to fullfill my need that, code done just first row of data, and do not find all combination to the end of data.
Any tips?
I hope somebody can help me with my code.<?xml:namespace prefix = o ns = "urn:schemas-microsoft-comfficeffice" /><o></o>
Idea is very simple: I have two columns of data to compare. It is montly results of some measurement. <o></o>
I need to find out non-logical results and with all corresponding combinations, e.g. in column E (were results from month ago) and in column F (were results from current month).
Non-logical results are all combinations in the way that results from one month do not follow results in the current month.
Correct, logical results for measurement results should be:
in month before is positive, and in current month is positive
in month before is negative, and in current month is negative
My code is as follows:
Sub SearchForProblemThenExit()
'Page 112
FinalRow = Cells(Rows.Count, 1).End(xlUp).Row
ProblemFound = False
For i = 2 To FinalRow
If Cells(i, 5).Value < 0 Then
If Cells(i, 6).Value > 0 Then
Cells(i, 8).Value = "Service Revenue"
Cells(i, 1).Resize(1, 8).Interior.ColorIndex = 4
Exit For
End If
End If
Next i
For i = 2 To FinalRow
If Cells(i, 5).Value > 0 Then
If Cells(i, 6).Value < 0 Then
Cells(i, 8).Value = "Service Revenue"
Cells(i, 1).Resize(1, 8).Interior.ColorIndex = 4
Exit For
End If
End If
Next i
For i = 2 To FinalRow
If Cells(i, 5).Value = 0 Then
If Cells(i, 6).Value < 0 Then
Cells(i, 8).Value = "Service Revenue"
Cells(i, 1).Resize(1, 8).Interior.ColorIndex = 4
Exit For
End If
End If
Next i
For i = 2 To FinalRow
If Cells(i, 5).Value = 0 Then
If Cells(i, 6).Value > 0 Then
Cells(i, 8).Value = "Service Revenue"
Cells(i, 1).Resize(1, 8).Interior.ColorIndex = 4
Exit For
End If
End If
Next i
For i = 2 To FinalRow
If Cells(i, 5).Value < 0 Then
If Cells(i, 6).Value = 0 Then
Cells(i, 8).Value = "Service Revenue"
Cells(i, 1).Resize(1, 8).Interior.ColorIndex = 4
Exit For
End If
End If
Next i
For i = 2 To FinalRow
If Cells(i, 5).Value > 0 Then
If Cells(i, 6).Value = 0 Then
Cells(i, 8).Value = "Service Revenue"
Cells(i, 1).Resize(1, 8).Interior.ColorIndex = 4
Exit For
End If
End If
Next i
End Sub
Credits for original code going to the book VBA & Macros: Microsoft Excel 2010, Chapter 5 - Looping
My main problem is, after i rewrite original code to fullfill my need that, code done just first row of data, and do not find all combination to the end of data.
Any tips?