Solved

Cross check data  and highlight

Posted on 2011-09-13
4
321 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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Introduction This Article briefly covers methods of calculating the NPV and IRR variants in Excel as well as the limitations in calculating and interpreting IRR results. Paraphrasing Richard Shockley, author of my favourite finance reference tex…
Improved? Move/Copy Add-in Replacement - How to avoid the annoying, “A formula or sheet you want to move or copy contains the name XXX, which already exists on the destination worksheet.” David Miller (dlmille)  It was one of those days… I wa…
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 create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.

758 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now