Matching columns and retaining result data

AndyT88

New Member
Joined
Dec 26, 2021
Messages
4
Office Version
  1. 2019
Platform
  1. Windows
I have a complete list of all sample ID's in column A.

Column C shows the samples that have been tested for pH (and thier corresponding result in column D)

1640506293817.png


Column B is a duplicate list which inserts blanks using the following VBA code:


VBA Code:
Sub Listduplicates()
    Dim rngA As Range
    Set rngA = Range([A1], Cells(Rows.Count, "A").End(xlUp))
    rngA.Offset(0, 1).Columns.Insert
    With rngA.Offset(0, 1)
        .FormulaR1C1 = _
        "=IF(ISNA(MATCH(RC[-1],C[1],0)),"""",INDEX(C[1],MATCH(RC[-1],C[1],0)))"
        .Value = .Value
    End With
End Sub


The Question: How do I now get the pH result (column D) to match with its corresponding Sample ID in column A?


Any help will be greatly appriciated. Many Thanks.
 
Last edited by a moderator:

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
Welcome to the MrExcel Message Board!

Cross-posting (posting the same question in more than one forum) is not against our rules, but the method of doing so is covered by #13 of the Forum Rules.

Be sure to follow & read the link at the end of the rule too!

Cross posted at: Matching columns and retaining result data
and Matching columns and retaining result data
If you have posted the question at more places, please provide links to those as well.

If you do cross-post in the future and also provide links, then there shouldn’t be a problem.
 
Upvote 0
How about
VBA Code:
Sub Listduplicates()
   Dim rngA As Range, Rng As Range
   Set rngA = Range([A1], Cells(Rows.Count, "A").End(xlUp))
   rngA.Offset(0, 1).Columns.Insert
   With rngA.Offset(0, 1)
      .FormulaR1C1 = _
      "=IF(ISNA(MATCH(RC[-1],C[1],0)),"""",INDEX(C[1],MATCH(RC[-1],C[1],0)))"
      .Value = .Value
   End With
   For Each Rng In Range("B:B").SpecialCells(xlBlanks).Areas
      Rng.Offset(, 1).Resize(, 2).Insert xlShiftDown
   Next Rng
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,064
Messages
6,122,941
Members
449,094
Latest member
teemeren

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