Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 562601
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T12:34:18+00:00 2026-05-13T12:34:18+00:00

Given I have the following <Sheet 1> Item QTY A 5 B 1 C

  • 0

Given I have the following

<Sheet 1>
Item    QTY
A        5
B        1
C        3


<Sheet 2>
Item    QTY
A        15
B        4
C        1
D        8

What is the best way to generate a report showing the difference between sheet 1 and 2?

Like

<Difference>
Item    QTY
A        10
B        3
C       -2
D        8
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T12:34:19+00:00Added an answer on May 13, 2026 at 12:34 pm

    In Excel VBA, use a Dictionary. Use your items from one of the sheets as keys, QTY as values. Put the item/QTY pairs of sheet 1 into the dictionary, then run through the items of sheet 2 update the dictionary accordingly to get the differences in there. Finally, put the result into sheet 3.

    EDIT: here is a complete example in code (you have to set a reference to the Microsoft Scripting runtime to get it working this way):

    Option Explicit
    Sub CreateDiff()
    
        Dim dict As New Dictionary
        Dim sh1 As Worksheet, sh2 As Worksheet, sh3 As Worksheet
        Dim i As Long, v As String
    
        Set sh1 = ThisWorkbook.Sheets("Sheet1")
        Set sh2 = ThisWorkbook.Sheets("Sheet2")
        Set sh3 = ThisWorkbook.Sheets("Sheet3")
        For i = 2 To sh1.Cells.SpecialCells(xlCellTypeLastCell).Row
            v = Trim(sh1.Cells(i, 1).Value)
            dict(v) = -sh1.Cells(i, 2).Value
        Next
        For i = 2 To sh2.Cells.SpecialCells(xlCellTypeLastCell).Row
            v = Trim(sh2.Cells(i, 1).Value)
            If dict.Exists(v) Then
                dict(v) = dict(v) + sh2.Cells(i, 2).Value
            Else
                dict(v) = sh2.Cells(i, 2).Value
            End If
        Next
        For i = 0 To dict.Count - 1
            v = dict.Keys(i)
            sh3.Cells(i + 2, 1) = v
            sh3.Cells(i + 2, 2) = dict(v)
        Next
    
    End Sub
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

given i have the following block of code (function(){ var mb = { abc:function(){
Given that I have the following WCF service: class LookUpService { public List<County> GetCounties(string
I have the following problem: I am given a tree with N apples, for
I have the following expression that should match the entire given word in case
I have the following html code (in the given order) <div id=content>...</div> <div id=footer>...</div>
Given I have two File objects I can think of the following implementation: public
I have the following code (generates a quadratic function given the a, b, and
I have the following SQL query I was given, but I am not sure
I have the following problem, given the following service contract, data contract, and service
I have the following scenarios: Scenario: Create a game with valid information Given I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.