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 |
open | 3001 | 1 | |
3001 | 2 |
What I need:
Old Sheet:
open | 3001 | 1 |
confirmed | 3001 | 2 |
open | 3001 | 1 | |
| 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