Excel Macro Code to add words to separate column

constantinet

New Member
Joined
Mar 9, 2017
Messages
16
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.
 

Some videos you may like

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.

alansidman

Well-known Member
Joined
Feb 26, 2007
Messages
5,687
Office Version
2019
Platform
Windows
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
Joined
Mar 9, 2017
Messages
16
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
Joined
Feb 26, 2007
Messages
5,687
Office Version
2019
Platform
Windows
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
 

Watch MrExcel Video

Forum statistics

Threads
1,102,470
Messages
5,487,072
Members
407,575
Latest member
Stephen66

This Week's Hot Topics

Top