Compare between two sheets

bumfart66

New Member
Joined
Aug 23, 2017
Messages
21
Office Version
  1. 365
Platform
  1. Windows
  2. MacOS
Hi , i have two sheets

Sheet One, column AB,C


Use DescriptionCircuit TypeName
USE01SmallTEST01
USE02SmallTEST02
USE03SmallTEST03
USE04SmallTEST04
USE05SmallTEST05
USE06SmallTEST06
USE07SmallTEST07
USE08SmallTEST08
USE09SmallTEST09
USE10SmallTEST10
USE11SmallTEST11
USE12SmallTEST12
USE13SmallTEST13
USE14SmallTEST14
USE15SmallTEST15
USE16SmallTEST16
USE17SmallTEST34
USE18SmallTEST35
USE19SmallTEST36
USE20SmallTEST37
USE21SmallTEST38
USE22SmallTEST39
USE23SmallTEST40
USE24SmallTEST41
USE25SmallTEST42
USE26SmallTEST43
USE27SmallTEST44


Sheet Two - column AB,C


StatusNameLength (m)
activeTEST0111746.63
activeTEST0211746.63
activeTEST0323493.25
activeTEST046732.72
activeTEST0540502.18
activeTEST06162008.73
activeTEST0720766.88
activeTEST083366.36
activeTEST0913465.43
activeTEST109416.77
activeTEST1120568.17
activeTEST12108823.46
activeTEST1393290.01
activeTEST14203796.95
activeTEST159145.56
activeTEST169145.56
activeTEST174572.78
activeTEST189145.56
activeTEST199145.56
activeTEST209145.56
activeTEST2136582.23
activeTEST2225744.69
activeTEST2312872.34
activeTEST2412872.34
activeTEST25154565.05
activeTEST263730.34
activeTEST277460.67
activeTEST287460.67
activeTEST297460.67
activeTEST307460.67
activeTEST317460.67
activeTEST327460.67
activeTEST3385997.57

What i would like, If the name on sheet two appears on sheet one, the length from sheet two is added to column D it would look like this

Use DescriptionCircuit TypeCircuit Reference NumberLength
USE01SmallTEST0111746.63
USE02SmallTEST0211746.63
USE03SmallTEST0323493.25
USE04SmallTEST046732.72
USE05SmallTEST0540502.18
USE06SmallTEST06162008.73
USE07SmallTEST0720766.88
USE08SmallTEST083366.36
USE09SmallTEST0913465.43
USE10SmallTEST109416.77
USE11SmallTEST1120568.17
USE12SmallTEST12108823.46
USE13SmallTEST1393290.01
USE14SmallTEST14203796.95
USE15SmallTEST159145.56
USE16SmallTEST169145.56
USE17SmallTEST34Not in sheet two
USE18SmallTEST35Not in sheet two
USE19SmallTEST36Not in sheet two
USE20SmallTEST37Not in sheet two
USE21SmallTEST38Not in sheet two
USE22SmallTEST39Not in sheet two
USE23SmallTEST40Not in sheet two
USE24SmallTEST41Not in sheet two
USE25SmallTEST42Not in sheet two
USE26SmallTEST43Not in sheet two
USE27SmallTEST44Not in sheet two
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
Does this do what you want?
(I didn't understand why/how the heading in column C in your sample results changed from "Name" to "Circuit Reference Number" so I ignored that.)

Test.xlsm
ABCD
1Use DescriptionCircuit TypeNameLength
2USE01SmallTEST0111746.63
3USE02SmallTEST0211746.63
4USE03SmallTEST0323493.25
5USE04SmallTEST046732.72
6USE05SmallTEST0540502.18
7USE06SmallTEST06162008.73
8USE07SmallTEST0720766.88
9USE08SmallTEST083366.36
10USE09SmallTEST0913465.43
11USE10SmallTEST109416.77
12USE11SmallTEST1120568.17
13USE12SmallTEST12108823.46
14USE13SmallTEST1393290.01
15USE14SmallTEST14203796.95
16USE15SmallTEST159145.56
17USE16SmallTEST169145.56
18USE17SmallTEST34Not in Sheet two
19USE18SmallTEST35Not in Sheet two
20USE19SmallTEST36Not in Sheet two
21USE20SmallTEST37Not in Sheet two
22USE21SmallTEST38Not in Sheet two
23USE22SmallTEST39Not in Sheet two
24USE23SmallTEST40Not in Sheet two
25USE24SmallTEST41Not in Sheet two
26USE25SmallTEST42Not in Sheet two
27USE26SmallTEST43Not in Sheet two
28USE27SmallTEST44Not in Sheet two
Sheet1
Cell Formulas
RangeFormula
D2:D28D2=IFNA(VLOOKUP(C2:C28,Sheet2!$B$2:$C$34,2,0),"Not in Sheet two")
Dynamic array formulas.
 
Upvote 0
You're welcome. Thanks for the confirmation.
 
Upvote 0
Good day @bumfart66.
Another option for you using macros. Paste the following code into the standard module.
VBA Code:
Option Explicit

Sub AddLengthToSheet1()
    Dim i           As Long

    Dim dict        As Object
    Set dict = CreateObject("Scripting.Dictionary")
    Application.ScreenUpdating = False

    With ThisWorkbook.Worksheets("Sheet2")

        For i = 2 To .Cells(.Rows.Count, "A").End(xlUp).Row

            If Not dict.exists(.Cells(i, "B").Value) Then
                dict.Add .Cells(i, "B").Value, .Cells(i, "C").Value
            End If

        Next i

    End With


    With ThisWorkbook.Worksheets("Sheet1")
        .Range(.Cells(2, "D"), .Cells(.Cells(.Rows.Count, "A").End(xlUp).Row, "D")).ClearContents

        For i = 2 To .Cells(.Rows.Count, "A").End(xlUp).Row

            If dict.exists(.Cells(i, "C").Value) Then
                .Cells(i, "D").Value = dict(.Cells(i, "C").Value)
            Else
                .Cells(i, "D").Value = "Not in sheet two"
            End If

        Next i

        .Range("D1").Value = "Length (m)"
        .Range(.Cells(2, "D"), .Cells(.Cells(.Rows.Count, "A").End(xlUp).Row, "D")).NumberFormat = "0.00"
        .Cells.Columns.AutoFit
    End With

    Set dict = Nothing
    Application.ScreenUpdating = True
End Sub
I hope I understood you correctly. I was glad to help you. Good luck.
 
Upvote 0

Forum statistics

Threads
1,223,941
Messages
6,175,541
Members
452,652
Latest member
eduedu

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