Loop through a range

G

Guest

Hello NG,
I'm trying to compare two columns of numbers to see if there are new entries
in the list.
I have a column of numbers (always in E) and I have another column of
numbers (always in J).
The numbers in column E are the numbers for invoices I've already checked,
the numbers in column J are for the numbers of invoices that are both new and
checked.
How can I compare the 2 columns and change the font color to red for the new
invoice numbers (invoices not checked) .
I have gotten this far and I don't know how to continue

Any help would be greatly appreciated
James

=============================================
Sub Check_Invoice_Number()


Sheets("Sheet1").Activate
Dim i As Integer
Dim RowCount As Integer
Dim CellVaLue

Application.ScreenUpdating = False

'get the number of rows from the first column for the loop (column E)

Range("E65536").Select
Selection.End(xlUp).Select
Range(Selection, Selection.End(xlUp)).Select
RowCount = Selection.Rows.Count

'define a starting place
Range("E1").Select


'Begining of
Loop----------------------------------------------------------------------------
'Loop through each of the rows of the spreadsheet
For i = 1 To RowCount


' look in column E, which is the 1st column for a duplicate
If (Cells(i + 1).Value) = (testvalue for column J) Then
CellVaLue = ActiveCell.Value
MsgBox CellVaLue
Else
CellVaLue = ActiveCell.Value
MsgBox CellVaLue

End If
Next
End Sub
--
 
T

Tom Ogilvy

select Column J (J1 should be the activeCell), then do Format, Conditional
Formatting

in the dialog, change Cell value is to Formula is

in the textbox put

=countif($E:$E,J1)=0

then click the format button and pattern tab, pick red.

then OK out.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top