# Excel Macro Code to add words to separate column

#### constantinet

##### New Member
I am looking for an excel macro code to do the following:

If the name "Jane Doe" is in column H then I need the name "John Doe" dropped into column I.

Thank you in advance for any help provided.

### Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.

#### alansidman

##### Well-known Member
Where would Excel find John Doe to know that it should go into column I. Is it shown somewhere else in a relationship to Jane Doe? Give us some more details on worksheet/workbook layout and arrangement.

#### constantinet

##### New Member
Jane Doe is find in column H and name repeats multiple times in column H, if the name Jane Doe is found in column H then I would like to drop the name John Doe into column I. John Doe is currently not on worksheet.

Thanks,
Tara

#### alansidman

##### Well-known Member
I suspect that there is more to this than a simple insertion of a name, but I will give you a simple code for this specific request. Keep in mind that this is specific to Jane Doe and will not work for any other names.

Code:
``````Sub JaneDoe
Dim i as long, lr as long
lr = range("A" & rows.count).end(xlup).row
For i = 1 to lr
If instr(Range("H" & i),"Jane Doe")>0 then
Range("I" & i)= "John Doe"
End if
Next i
End Sub``````

#### constantinet

##### New Member
Thank you so much, code worked.