Cells Relating to Each Other...

Nuyorican

Board Regular
Joined
Jun 17, 2003
Messages
206
Good Afternoon to All...

I have 2 columns, as the source information. Column # 1 consists of 6 digit numbers. Column # 2 consists of names that are associated to each number in Column # 1.

I would like to key in the info of #1 (the 6 digit number) in any cell and have the name associated with that number in the cell to the right. So my result is A1 is "678905" and B1 is "Jack Brown".

Thank you.
Benito
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
You can do it with event code. Assuming that the two source columns are A and B and no other data will be entered in those two columns.
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Cells.Count > 1 Then Exit Sub
If Not Intersect(Target, Range("A:B")) Is Nothing Then Exit Sub
Application.EnableEvents = False
Dim fn As Range
Set fn = Range("A:A").Find(Target.Value, , xlValues)
    If Not fn Is Nothing Then
        Target.Offset(, 1) = fn.Offset(, 1)
    End If
Application.EnableEvents = True
End Sub
 
Last edited:
Upvote 0
I am not proficient in the VB Editor, but I opened the editor, pasted the code in a module and I can’t run the macro.
 
Upvote 0
I am not proficient in the VB Editor, but I opened the editor, pasted the code in a module and I can’t run the macro.
Delete the code from any numbered module you might have copied it to. Then, right click the name tab of the sheet where your two columns of data reside. Click 'View Code' in the pop up menu. That will open the vb editor to the Sheet code module. You can verify that by looking at the top margin of the editor where it should show something like
WorkbookName [Sheet1 (Code)]
Paste the code into that code window, save your workbook as a macro enabled workbook (.xlsm) and close the vb editor. The code will now run when you make changes on the worksheet. It will only execute the copy and paste when entries are made anywhere but columns A and B.
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,327
Members
452,635
Latest member
laura12345

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top