|Errors produced by VLOOKUP can be handled using an IF function to check for the error. |
If VLOOKUP can't find the value it is looking for, it will return #N/A. To eliminate the error, you would use the ISNA function to check for the error and return something else, such as a text string. Something like this, which has not been tested:
However, VLOOKUP only finds the first occurrence of the lookup_value but you appear to have multiple matching values in Sheet 2.
Perhaps you could create a column of subtotals for each ID and then use on that column to import the data.
Click Here Before Posting Data or VBA Code ---> How To Post Data or Code.