I have a column with sample data(duplicate):

```
A10
B20
C30
A10
C30
C30
...
```

I want to replace each value with ID hold in other columns:

```
A10 - ID1
B20 - ID2
C30 - ID3
```

I have to many id’s to do this with the ordinary replace. Is there a tricky way to do this or I should use other technique (like move the data in some program language and to do the replacement there).

Thank you in advance.

Joro

You can do it without any VBA, using `VLOOKUP`

. Put all your key/value pairs in a 2-column array, e.g., D1:E3. Assuming your column of data starts in A1, put this formula in column B1:

```
= VLOOKUP(A1, $D$1:$E$3, 2, FALSE)
```

then copy-paste down.

If not all your original values are mapped into a new ID, the VLOOKUP will return ‘#N/A’. If you want to keep the original values for these, your formula will be a bit more complex:

```
= IF(ISNA(VLOOKUP(A1, $D$1:$E$3, 2, FALSE), A1, VLOOKUP(A1, $D$1:$E$3, 2, FALSE)))
```

### Answer：

Here’s a macro for searching for a series of values/strings and replacing them with a new set of values/strings:

There’s a sample sheet there you can use to test it out, too.

To use the macro as is:

- create a new sheet called
**Categories** - put the values to find in column A
- put the replacement values in column B
- Bring up your main sheet onscreen (sample sheet it’s called
**Data**) - Run the macro

Tags: excelexcel, replace