Create a report dashboard to compare between two sheets data

almaita

New Member
Joined
Mar 12, 2022
Messages
1
Office Version
  1. 2016
Platform
  1. Windows
Hi,

I have the below drug list shared by insurance companies each Monday, this list always varies with multiple fields such as drugs added/removed, drugs shifted to tier 2 from tier 3 or vise versa, unit price increase.. and all the the fields.

example

February 21 sheet lets call it sheet 1 in the workbook
New Drug CodeInsurance PlanNew TierPackage NameGeneric NameStrengthDosage FormPackage SizePackage Price to PublicPackage Price to PharmacyUnit Price to PublicUnit Price to PharmacyStatusDelete Effective DateLast ChangeAgent NameManufacturer Name
J28-6164-06355-01NCI-Non Coverage Item3PROSTOFORTE(Ayruvedic) ProstoforteCombinationCapsules50s62.550.651.251.01Active8 August 2018NUPAL REMEDIES TRADINGNew Udaya Pharmacy & Ayurvedic Laboratories, INDIA
T96-7632-07527-01NCI-Non Coverage Item3MAGNESIUM PHOSPHORICUM 6X- ADLER PHARMA(Hemeopathy) Magnesium Phosphoricum250 mgTablets200s48360.240.18Active10 November 2019ULTRAPHARMA DRUG STOREAdler Pharma Produktion und Vertrieb GmbH, AUSTRIA
D98-2596-00001-01NCI-Non Coverage Item3IRICAR(Homeopathy)CombinationCream50g48364836Active8 June 2016ULTRA MEDICAL STORE (ULTRAMED)Deutsche Homoopathie Union, GERMANY


February 28 updated sheet, lets call it sheet 2 in the workbook
New Drug CodeInsurance PlanNew TierPackage NameGeneric NameStrengthDosage FormPackage SizePackage Price to PublicPackage Price to PharmacyUnit Price to PublicUnit Price to PharmacyStatusDelete Effective DateLast ChangeAgent NameManufacturer Name
J28-6164-06355-01NCI-Non Coverage Item2PROSTOFORTE(Ayruvedic) ProstoforteCombinationCapsules50s62.550.651.251.01Active8 August 2018NUPAL REMEDIES TRADINGNew Udaya Pharmacy & Ayurvedic Laboratories, INDIA
T96-7632-07527-01NCI-Non Coverage Item3MAGNESIUM PHOSPHORICUM 6X- ADLER PHARMA(Hemeopathy) Magnesium Phosphoricum250 mgTablets200s603610.18Active10 November 2019ULTRAPHARMA DRUG STOREAdler Pharma Produktion und Vertrieb GmbH, AUSTRIA
G32-0766-00004-01NCI-Non Coverage Item3CALMVALERA HEVERT(Homeopathy) (CALMVALERA HEVERT)CombinationOral Solution50ml72547254Active27 November 2018ULTRA MEDICAL STORE (ULTRAMED)Hevert-Arzneimittel GmbH & Co. KG, GERMANY


i need a sheet in the workbook titled lets say "Report" that capture all the differences between both sheets. for example (sheet1 row 3 IRICAR is removed from the update, while "CALMVALERA HEVERT", PROSTOFORTE in sheet 1 was in tier 3, it got downgraded to tier 2 in the updated sheet, the package price to public column jumped for Magnesium from 48 to 60.

how can i show all differences between both sheets, and if that can be solved by VBA or formulas, can i also have the cells highligted in red for the drugs removed, and in green for the druges added, same for the prices increase?

*Note: i need to capture all changes in the sheet and not only prices
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
Ok almaita,

This did take some time so hope this works for you
VBA Code:
'This is a 2 part process
'First to check all the Sheet2 data against Sheet 1 and report all changes and additions
'Then check if there are any removed and add them to the report

Sub Run_Report()
Dim ShOld As Worksheet
Dim ShNew As Worksheet
Dim ShRpt As Worksheet
Dim Drug As Range
Dim DrugCols As Collection
Dim RptRow As Integer
Dim cell As Range
Dim Itm As Integer
Set DrugCols = New Collection
Set ShOld = ThisWorkbook.Sheets("Sheet1")
Set ShNew = ThisWorkbook.Sheets("Sheet2")
Set ShRpt = ThisWorkbook.Sheets("Report")
RptRow = 2
Itm = 1
ShRpt.Cells.Delete
'Write Headers
ShOld.Range("1:1").Copy ShRpt.Range("A1")
For Each Drug In ShNew.Range("A2:A1500").Cells
    If Drug = "" Then Exit For
    'Check for changes and additions
    Set DrugCols = Process_Drug(Drug, ShOld, False)
    'Write changes and additions
    For Each cell In Range(ShRpt.Cells(RptRow, 1), ShRpt.Cells(RptRow, 17)).Cells
        If cell.Value = "" Then
            cell.Value = DrugCols(Itm)(0)
            If DrugCols(Itm)(1) = False Then cell.Interior.Color = vbGreen
            Itm = Itm + 1
        Else
            Exit For
        End If
    Next cell
    Itm = 1
    RptRow = RptRow + 1
Next Drug
For Each Drug In ShOld.Range("A2:A1500").Cells
    If Drug = "" Then Exit For
    'Check for Deletions and turn them red
    Set DrugCols = Process_Drug(Drug, ShNew, True)
    'Write changes and additions
    If DrugCols.Count <> 0 Then
        For Each cell In Range(ShRpt.Cells(RptRow, 1), ShRpt.Cells(RptRow, 17)).Cells
            cell.Value = DrugCols(Itm)(0)
            If DrugCols(Itm)(1) = False Then cell.Interior.Color = vbRed
            Itm = Itm + 1
        Next cell
    RptRow = RptRow + 1
    End If
Next Drug
ShRpt.Columns.AutoFit
End Sub


Function Process_Drug(DrugToCheck As Range, SheetToCheck As Worksheet, FindRemoved As Boolean) As Collection
    'This will take 1 row of a drug and compair it to all drugs in the other sheet
    Dim Drug As Range
    Dim DrugCol As Integer
    Dim Col(1) As Variant
    Set Process_Drug = New Collection
    For Each Drug In SheetToCheck.Range("A2:A1500").Cells
        If Drug = "" Then Exit For
        If Drug = DrugToCheck Then
            If FindRemoved Then Exit Function
            'Check both entries for differences
            For DrugCol = 0 To 16
                If DrugToCheck.Offset(, DrugCol).Value = Drug.Offset(, DrugCol).Value Then
                    Col(0) = DrugToCheck.Offset(, DrugCol).Value
                    Col(1) = True
                Else
                    Col(0) = DrugToCheck.Offset(, DrugCol).Value
                    Col(1) = False
                End If
                Process_Drug.Add Col
                Erase Col()
            Next DrugCol
            Exit Function
        End If
    Next Drug
    If Process_Drug.Count = 0 Then
        For DrugCol = 0 To 16
            Col(0) = DrugToCheck.Offset(, DrugCol).Value
            Col(1) = False
            Process_Drug.Add Col
            Erase Col()
        Next DrugCol
    End If
End Function
almaita.xlsm
ABCDEFGHIJKLMNOPQ
1New Drug CodeInsurance PlanNew TierPackage NameGeneric NameStrengthDosage FormPackage SizePackage Price to PublicPackage Price to PharmacyUnit Price to PublicUnit Price to PharmacyStatusDelete Effective DateLast ChangeAgent NameManufacturer Name
2J28-6164-06355-01NCI-Non Coverage Item3PROSTOFORTE(Ayruvedic) ProstoforteCombinationCapsules50s62.550.651.251.01Active8-Aug-18NUPAL REMEDIES TRADINGNew Udaya Pharmacy & Ayurvedic Laboratories, INDIA
3T96-7632-07527-01NCI-Non Coverage Item3MAGNESIUM PHOSPHORICUM 6X- ADLER PHARMA(Hemeopathy) Magnesium Phosphoricum250 mgTablets200s48360.240.18Active10-Nov-19ULTRAPHARMA DRUG STOREAdler Pharma Produktion und Vertrieb GmbH, AUSTRIA
4D98-2596-00001-01NCI-Non Coverage Item3IRICAR(Homeopathy)CombinationCream50g48364836Active8-Jun-16ULTRA MEDICAL STORE (ULTRAMED)Deutsche Homoopathie Union, GERMANY
Sheet1


almaita.xlsm
ABCDEFGHIJKLMNOPQ
1New Drug CodeInsurance PlanNew TierPackage NameGeneric NameStrengthDosage FormPackage SizePackage Price to PublicPackage Price to PharmacyUnit Price to PublicUnit Price to PharmacyStatusDelete Effective DateLast ChangeAgent NameManufacturer Name
2J28-6164-06355-01NCI-Non Coverage Item2PROSTOFORTE(Ayruvedic) ProstoforteCombinationCapsules50s62.550.651.251.01Active8-Aug-18NUPAL REMEDIES TRADINGNew Udaya Pharmacy & Ayurvedic Laboratories, INDIA
3T96-7632-07527-01NCI-Non Coverage Item3MAGNESIUM PHOSPHORICUM 6X- ADLER PHARMA(Hemeopathy) Magnesium Phosphoricum250 mgTablets200s603610.18Active10-Nov-19ULTRAPHARMA DRUG STOREAdler Pharma Produktion und Vertrieb GmbH, AUSTRIA
4G32-0766-00004-01NCI-Non Coverage Item3CALMVALERA HEVERT(Homeopathy) (CALMVALERA HEVERT)CombinationOral Solution50ml72547254Active27-Nov-18ULTRA MEDICAL STORE (ULTRAMED)Hevert-Arzneimittel GmbH & Co. KG, GERMANY
Sheet2


almaita.xlsm
ABCDEFGHIJKLMNOPQ
1New Drug CodeInsurance PlanNew TierPackage NameGeneric NameStrengthDosage FormPackage SizePackage Price to PublicPackage Price to PharmacyUnit Price to PublicUnit Price to PharmacyStatusDelete Effective DateLast ChangeAgent NameManufacturer Name
2J28-6164-06355-01NCI-Non Coverage Item2PROSTOFORTE(Ayruvedic) ProstoforteCombinationCapsules50s62.550.651.251.01Active8/08/2018NUPAL REMEDIES TRADINGNew Udaya Pharmacy & Ayurvedic Laboratories, INDIA
3T96-7632-07527-01NCI-Non Coverage Item3MAGNESIUM PHOSPHORICUM 6X- ADLER PHARMA(Hemeopathy) Magnesium Phosphoricum250 mgTablets200s603610.18Active10/11/2019ULTRAPHARMA DRUG STOREAdler Pharma Produktion und Vertrieb GmbH, AUSTRIA
4G32-0766-00004-01NCI-Non Coverage Item3CALMVALERA HEVERT(Homeopathy) (CALMVALERA HEVERT)CombinationOral Solution50ml72547254Active27/11/2018ULTRA MEDICAL STORE (ULTRAMED)Hevert-Arzneimittel GmbH & Co. KG, GERMANY
5D98-2596-00001-01NCI-Non Coverage Item3IRICAR(Homeopathy)CombinationCream50g48364836Active8/06/2016ULTRA MEDICAL STORE (ULTRAMED)Deutsche Homoopathie Union, GERMANY
Report
 
Upvote 0
The only part I think should be added, but only if you use a new sheet everytime new data comes in. Is for there a way for the user to select the old sheet and the new sheet. You can do this be loading up a user form with 2 combo boxes and an OK button
 
Upvote 0

Forum statistics

Threads
1,223,236
Messages
6,170,912
Members
452,366
Latest member
TePunaBloke

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top