Need this code updated to get a specific output Based on values in Columns B and C

Gmoney69

New Member
Joined
Aug 18, 2022
Messages
5
Office Version
  1. 365
Platform
  1. Windows
VBA Code:
Sub CopyCode()
    Application.ScreenUpdating = False
    Dim v As Variant, i As Long, srcRng As Range, srcWS As Worksheet, desWS As Worksheet
    Set srcWS = Sheets("Sheet1")
    Set desWS = Sheets("Sheet2")
    v = srcWS.Range("A2", srcWS.Range("A" & Rows.Count).End(xlUp)).Resize(, 2).Value
    Set srcRng = desWS.Range("B2", desWS.Range("B" & Rows.Count).End(xlUp))
    For i = 1 To UBound(v)
        If Not IsError(Application.Match(v(i, 2), srcRng, 0)) Then
            x = Application.Match(v(i, 2), srcRng, 0)
            With desWS.Range("A" & x + 1)
                .Value = v(i, 1)
                .Interior.ColorIndex = srcWS.Range("B" & i + 1).Interior.ColorIndex
            End With
        End If
    Next i
    Application.ScreenUpdating = True
End Sub


Right now this code copies notes and colors from Column A into Column A on the new sheet based on column B. My Document Numbers in Column B contain duplicates but each row has a Line Number in Column C which indicates a certain line of the document. I need it to take into account columns B and C together.

Current Macro Spits this out.
Old sheet says:
open
3001​
1​
confirmed
3001​
2​
New sheet after Running the Macro:
open
3001​
1​
3001​
2​

What I need:
Old Sheet:
open
3001​
1​
confirmed
3001​
2​
New Sheet after Running the Macro:
open
3001​
1​
confirmed
3001​
2​

Here's a example of the data I'm dealing with. Of course the notes are a lot more detailed and there's more information on the reports but these are the only relevant columns. Report_Macro_EX.xlsx
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result

Forum statistics

Threads
1,223,231
Messages
6,170,884
Members
452,364
Latest member
springate

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