I have code that allows me to copy and paste thousands of lines of information based on matching identifiers. However, the code does not seem to work well in the pivot table. On sheet 4, the identifiers are placed in the pivot table, and in sheet 1 - identifiers, and the information is not in the pivot table (both identifiers on sheet 4 and 1 are in the same column, which is column A). However, the identifiers appeared more than once in sheet 1. Thus, when I try to run the code, it gives the error below Cannot enter a null value as an item or field name in pivot table report" on the line 'rngTracker.Value = arrT .
Sub Sample() Dim rngTracker As Range Dim rngMaster As Range Dim arrT, arrM Dim dict As Object, r As Long, tmp With Workbooks("FAST_Aug2015_Segment_Out_V1.xlsm") Set rngTracker = .Sheets("Sheet4").Range("A5:D43000") Set rngMaster = .Sheets("Sheet1").Range("A2:C200000") End With 'get values in arrays arrT = rngTracker.Value arrM = rngMaster.Value 'load the dictionary Set dict = CreateObject("scripting.dictionary") For r = 1 To UBound(arrT, 1) dict(arrT(r, 1)) = r Next r 'map between the two arrays using the dictionary For r = 1 To UBound(arrM, 1) tmp = arrM(r, 1) If dict.exists(tmp) Then arrT(dict(tmp), 4) = arrM(r, 3) End If Next r rngTracker.Value = arrT 'Error shown on this line' End Sub
Above is the code that I have and gave an error, as mentioned above. Would thank for any help. Thank you. :) The image of the pivot table in sheet 4 is shown below. The column heading, called "Acc Seg", is not part of the pivot table, but that is where the data will be inserted from sheet 1 when both identifiers in sheet 4 and sheet 1 match. 
source share