Solved

Cross check data  and highlight

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

A little background as to how I came to I design this code: Around 5 years ago I designed an add-in that formatted Excel files to a corporate standard, applying different cell colours and font type depending on whether the cells contained inputs,…
Dealing with unintended Excel Active-X resizing quirks (VBA code simulates "self correction") David Miller (dlmille) Intro Not everyone is a fan of Active-X controls in spreadsheets (as opposed to the UserForm approach, the older Form controls …
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.

920 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

12 Experts available now in Live!

Get 1:1 Help Now