[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Data quality check

Posted on 2011-02-25
2
Medium Priority
?
227 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 46

Accepted Solution

by:
aikimark earned 2000 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Excel can be a tricky bit of software to get your head around. Whilst you’ll be able to eventually get to grips with the basic understanding of how to get by, there are a few Excel tips that not everybody will even know about let alone know how to d…
If you need to forecast numbers -- typically for finance -- the Windows and Mac versions of Excel 2016 have a basket of tools to get the job done.
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.
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.

834 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