So I had a great deal of help coming up with this code which works flawlessly but I was wanting to know if anyone can see a way to do two changes, 1) Make it match both column A and column L so be a match and B if no match is found then add the record to the next available row?
Thanks in advance
Thanks in advance
Code:
Sub UpdateRun() Application.ScreenUpdating = False
Application.EnableEvents = False
Dim Wb As Workbook, Wbk As Workbook, Ws As Worksheet, Nws As Worksheet, RDPiv As Worksheet
Set Wb = ThisWorkbook
Set Ws = Wb.Sheets("Today")
If Ws.Range("E3") > 0 Then
Set Wbk = Workbooks.Open(Fl.Range("B9").Value)
Set Nws = Wbk.Sheets("Data")
Set RDPiv = Wbk.Sheets("Pivot")
Dim path As String, Val As String, i As Long, v1, v2
'----------------------------Update status, cause, and comments for current records---------------------------
v1 = Ws.Range("A3", Ws.Range("A" & Rows.Count).End(xlUp)).Value
v2 = Nws.Range("A3", Nws.Range("A" & Rows.Count).End(xlUp)).Value
With CreateObject("Scripting.Dictionary")
For i = 1 To UBound(v2, 1)
Val = v2(i, 1)
If Not .Exists(Val) Then
.Add Val, i + 2
End If
Next i
For i = 1 To UBound(v1, 1)
Val = v1(i, 1)
If .Exists(Val) Then
Nws.Cells(Nws.Range("A:A").Find(Val, LookIn:=xlValues, lookat:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row, "B") = Ws.Cells(i + 2, "B")
Nws.Cells(Nws.Range("A:A").Find(Val, LookIn:=xlValues, lookat:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row, "C") = Ws.Cells(i + 2, "C")
Nws.Cells(Nws.Range("A:A").Find(Val, LookIn:=xlValues, lookat:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row, "T") = Ws.Cells(i + 2, "T")
End If
Next i
End With
'-----------------Refresh's Pivot table data-----------------------
RDPiv.Activate
ActiveWorkbook.RefreshAll
Wbk.Close True
Wb.Save
End If
Wb.RefreshAll
Application.EnableEvents = True
Application.ScreenUpdating = True
End Sub