Locate duplicate values in a column, copy/paste adjacent value

davidanaya11579

New Member
Joined
Dec 26, 2017
Messages
11
I'm working on a report with thousands of entries. For some reason, the report only returns data in column C the first time a value appears in column B, for all subsequent entries of that value(B), Column C remains empty. I need to locate all duplicate values in column B, and copy the value of Column C into all subsequent entries.

Example of Raw Report:
LoadNumPrim Load#SSLine B/L
237098864237098864
238921496238921496238921496WAW
240817258240817258240817258NGB
242967262242967262MSCUJR543586
245434172242967262
242984183242984183HLCUCHI171002103
242988571242988571HLCUCHI171034120
242989105242988571
242989108242988571

<tbody>
</tbody><colgroup><col span="2"><col></colgroup>
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
If your data in column B is always sorted so that the same values are always together as in the sample you posted, then this macro should do what you want. Shouldn't the first value in column B (237098864) have data to the right in column C since it is the first time it appears? If you place a value in C2, the macro should work.
Code:
Sub CopyVal()
    Application.ScreenUpdating = False
    Dim LastRow As Long
    LastRow = Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
    Dim rng As Range
    For Each rng In Range("C2:C" & LastRow)
        If rng = "" Then
            rng = rng.Offset(-1, 0)
        End If
    Next rng
    Application.ScreenUpdating = True
End Sub
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,827
Messages
6,121,821
Members
449,049
Latest member
cybersurfer5000

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