Logo 
Search:

MS Office Answers

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds
  Question Asked By: Koila Malik   on Aug 18 In MS Office Category.

  
Question Answered By: Fairuzah Alam   on Aug 18

We guess you want to compare  line numbers.
if a line number does not appear in sheet2, color  it red.
Try this

Sub m()
Dim mws As Worksheet
Dim cws As Worksheet

Dim mrng As Range
Dim crng As Range
Dim c As Range

Dim awf As WorksheetFunction
Set awf = Application.WorksheetFunction

Sheets(1).Select
Set mws = Sheets(1)
Set mrng = Range(Cells(2, 2), Cells(2, 2).End(xlDown))

Sheets(2).Select
Set cws = Sheets(2)
Set crng = Range(Cells(2, 2), Cells(2, 2).End(xlDown))

For Each c In mrng
If awf.CountIf(crng, c) <> 1 Then mws.Cells(c.Row, 1).Resize
(1, 6).Interior.Color = vbRed
Next c

Sheets(1).Select
End Sub

Share: 

 

This Question has 3 more answer(s). View Complete Question Thread

 
Didn't find what you were looking for? Find more on compare data from different worksheets Or get search suggestion and latest updates.


Tagged: