Solved

Cross check data  and highlight

Posted on 2011-09-13
4
323 Views
Last Modified: 2012-08-14
Hi Experts,

I would like to request Experts help create a macro to cross check data in column B (Source_ sheet) with data in column B (Data_sheet). The data from Source sheet (Column B)  are generally listed at the end of the list in column B in the Data Sheet.

If the data on the source sheet (Column B) not available at Data sheet, the cell need to highlight with "Red" color. Please ignore data starts with "uration" and "------" during crosschecking process. Hope Experts could help me create this feature.

 
Track-Data.xls
0
Comment
Question by:Cartillo
  • 2
4 Comments
 
LVL 3

Accepted Solution

by:
heideld earned 500 total points
ID: 36530050
During a project w while back I modified a bunch code snippets I found on the web to fit my needs, the original sources are unknown...  You can probably do something with this and make it work for you...  (FYI, I was under the gun and never went back to clean it up and make it pretty)




Sub SelectRangeBetween()
    Dim CompareRange As Variant, x As Variant, y As Variant, z As Variant, PDIAddress As Variant, FindingRange As Variant

 
    Set CompareRange = Workbooks("FILENAMEHERE.xlsm"). _
    Worksheets("Sheet2").Range("A2:A675")
    Worksheets("Sheet1").Activate
    Worksheets("Sheet1").Range("A1").Activate
   
Set SelectionRange = Range("D8568:D21861")
    For Each x In SelectionRange

        For Each y In CompareRange

LookY = y.Value


'Set FoundAddress = Cells.Find(LookY, LookIn:=xlValues, After:=ActiveCell)
Set FoundAddress = Cells.Find(LookY, After:=Range("d8568"), LookIn:=xlValues)

 If Not FoundAddress Is Nothing Then

 Worksheets("Sheet1").Activate
            Worksheets("Sheet1").Range(FoundAddress.Address).Activate
 
           
            'This is for when Target is in different Column.
           If FoundAddress.Value = Null Then
            FoundAddress.Offset(0, -2) = y
            FoundAddress.Offset(0, -1) = y.Offset(0, 1)
           ' x.Offset(-1, -2) = x
          '  x.Offset(-1, -1) = y.Offset(0, 1)
            End If
           
            Worksheets("Sheet1").Activate
           
        Worksheets("Sheet1").Range(FoundAddress.Address).Activate
            Set PDIAddress = Cells.Find("PDI:", LookIn:=xlValues, After:=ActiveCell)
           

                If Not PDIAddress Is Nothing Then
                    PDIAddress = PDIAddress.Address
           xAdd = FoundAddress.Offset(0, -3).Address
                    Set FindingRange = Range(xAdd, PDIAddress)
                    FindingRange.Resize(FindingRange.Rows.Count - 1, FindingRange.Columns.Count + 2).Interior.ColorIndex = 3
       
                        With FindingRange.Resize(FindingRange.Rows.Count - 1)
                        .Offset(0, 1) = y
                        .Offset(0, 2) = y.Offset(0, 1)
                                             
                       
                        End With
                       
                Else
                MsgBox ("Value Not Found")
                End If
             End If
        Next y
    Next x
End Sub


0
 
LVL 8

Expert Comment

by:ragnarok89
ID: 36530265
Assuming that the data appears in the same order on the destination sheet, why not just use conditional formatting? If cell is blank, highlight in red.
0
 

Author Comment

by:Cartillo
ID: 36530448
Hi ragnarok89,

I do agree with you but the problem is I'm going to use the sample sheet for crosschecking other data as well by clearing the whole data before resume with a new set of data. That the reason I'm looking for VBA solution instead of conditional formatting. Also intent to combine with other module. Hope you will consider my request.
0
 

Author Closing Comment

by:Cartillo
ID: 37164561
Hi,

Thanks for the help.
0

Featured Post

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction While answering a recent question (http:/Q_27311462.html), I created an alternative function to the Excel Concatenate() function that you might find useful.  I tested several solutions and share the results in this article as well as t…
This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.

822 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question