Solved

Data quality check

Posted on 2011-02-25
2
218 Views
Last Modified: 2012-05-11
Hi,

i have a report where i would like to create a sub to perform a check.

I have data in the two blocks (attached) that will always change from 1 day to the next.

I have highlighted in yellow "Today" and "Yesterday"

I would like some code that can read the data in "Today" and "Yesterday" and if it is identical, create a warning message "Data Identical"

The thing is, it must check lines up to the black fill and then move down and so on. I have labled the data areas that need to be checked "Report 1-9"

If it is long code to write, if i get the beginning, i should be able to extrapolate

Thanks
Seamus
Example.xls
0
Comment
Question by:Seamus2626
2 Comments
 
LVL 45

Accepted Solution

by:
aikimark earned 500 total points
ID: 34981403
I named the two ranges Today and Yesterday and ran the following routine.

Option Explicit

Public Sub CompareData()
  'compares Today and Yesterday named ranges
  Dim rngToday As Range
  Dim rngYesterday As Range
  Dim rngTcell As Range
  Dim boolFirstTime As Boolean
  
  Set rngToday = ActiveSheet.Range("Today")
  Set rngYesterday = ActiveSheet.Range("Yesterday")
  
  If (rngToday.Columns.Count = rngYesterday.Columns.Count) _
    And (rngToday.Rows.Count = rngYesterday.Rows.Count) Then
  Else
    MsgBox "Today and Yesterday ranges are not the same size", vbCritical, "Range size difference"
    Exit Sub
  End If
  
  
  boolFirstTime = True
  For Each rngTcell In rngToday
    If rngTcell.Value <> rngYesterday.Cells(rngTcell.Row - rngToday.Row + 1, rngTcell.Column - rngToday.Column + 1).Value Then
    Else
      If boolFirstTime Then
        boolFirstTime = False   'skip header cell
      Else
        Exit Sub
      End If
    End If
  Next
  MsgBox "Data Identical", vbCritical, "Range Data Identical"
End Sub

Open in new window

0
 

Author Closing Comment

by:Seamus2626
ID: 34981456
Thats great aikimark, thank you very much
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

A2 = A1 That kind of cell reference is relative.  If you copy it from A2 to B2, then B2 will get this: B2 = B1 That's all fine and good, but if you then insert a new row above row 2, you'll find: A3 = A1 B3 = B1 This is intentional. …
How to quickly and accurately populate Word documents with Excel data, charts and images (including Automated Bookmark generation) David Miller (dlmille) Synopsis In this article you’ll learn how to use ExcelToWord! to copy data,charts, shapes …
The viewer will learn how to simulate a series of coin tosses with the rand() function and learn how to make these “tosses” depend on a predetermined probability. Flipping Coins in Excel: Enter =RAND() into cell A2: Recalculate the random variable…
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.

707 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

14 Experts available now in Live!

Get 1:1 Help Now