Hello All,
I receive a report on a regular basis with 17 columns and a variable number of rows. I want to highlight all of the equivalent entries in one worksheet (worksheet 1) with a single column of entries from another worksheet (worksheet 2), again with any number of rows.
Please see the code...
I receive a report on a regular basis with 17 columns and a variable number of rows. I want to highlight all of the equivalent entries in one worksheet (worksheet 1) with a single column of entries from another worksheet (worksheet 2), again with any number of rows.
Please see the code...
VBA Code:
Private Sub CommandButton2_Click()
'Highlight duplicates on both sheets
Dim ws As Worksheet
'The number of rows of data in the PO Generator File
Dim iRowsCount As Integer
iRowsCount = Worksheets(1).UsedRange.Rows.Count
'The number of columns of data in the PO Generator File
Dim iColumnsCount As Integer
iColumnsCount = Worksheets(1).UsedRange.Columns.Count
'The number of entries or tags to be checked
Dim tagCount As Integer
Worksheets(2).Activate
tagCount = Worksheets(2).cells(Rows.Count, 1).End(xlUp).Row
'The program seems to work until this point
Dim iRows As Integer
Dim iCols As Integer
Dim iTags As Integer
For iRows = 1 To iRowsCount
For iCols = 1 To iColumnsCount
For iTags = 1 To tagCount
If Worksheets(1).cells(iRows, iCols).Value = Worksheets(2).cells(iTags).Value Then
Worksheets(1).cells(iRows, iCols).Interior.ColorIndex = 26
Worksheets(2).cells(iTags).Interior.ColorIndex = 28
End If
Next iTags
'...need to cycle through every entry in sheet2, column A
Next iCols
Next iRows
For Each ws In Worksheets
ws.Activate
Debug.Print ws.Name
Next
Worksheets(1).Activate
End Sub
Last edited by a moderator: