ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Loop through a range (https://www.excelbanter.com/excel-programming/327102-loop-through-range.html)

James

Loop through a range
 
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
--


Tom Ogilvy

Loop through a range
 
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.

--
Regards,
Tom Ogilvy


"James" wrote in message
...
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
--





All times are GMT +1. The time now is 10:19 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com