Looking for names in a list and copying to random numbered cells

katana_flyer

New Member
Joined
Feb 19, 2020
Messages
17
Office Version
  1. 2013
Platform
  1. Windows
Hello, trying to do this without vba if possible.

Sheet 1 contains
- a list of 15 names in column C
- a list of student number in column A

Sheet 2
- Has student’s numbers in cells scattered throughout the sheet in various cells. There are multiple cases of each students number on the sheet.

Object. As the list of names is keyed in on sheet 1, the corresponding student number on sheet 2 automatically changes to the students name.

I’m sure there are other threads, I’m just not sure what to look up as a rookie excel/computer guy.

Thanks for any help ,
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
If the cells in Sheet 2 have the student numbers simply typed into the various cells, then what you are asking is not possible without vba.

However, if instead of entering, say, the student number 44 in cell D5 of Sheet 2, you could put this formula.
Excel Formula:
=IFNA(VLOOKUP(44,Sheet1!$A$2:$C$1000,3,0),44)
If 44 does not yet exist in Sheet 1 then D5 in Sheet 2 will say 44.
Once 44 is entered in column A of Sheet 1 then D5 on Sheet 2 would automatically change to whatever is in column C of Sheet 1 on the row corresponding to the newly entered 44.
 
Upvote 0
If the cells in Sheet 2 have the student numbers simply typed into the various cells, then what you are asking is not possible without vba.

However, if instead of entering, say, the student number 44 in cell D5 of Sheet 2, you could put this formula.
Excel Formula:
=IFNA(VLOOKUP(44,Sheet1!$A$2:$C$1000,3,0),44)
If 44 does not yet exist in Sheet 1 then D5 in Sheet 2 will say 44.
Once 44 is entered in column A of Sheet 1 then D5 on Sheet 2 would automatically change to whatever is in column C of Sheet 1 on the row corresponding to the newly entered 44.
Thank you. I might be able to make that work. Alternatively, if I had to use vba, would it be easier? As of now, yes the student’s numbers have simply been entered in various cells around sheet 2.
 
Upvote 0
if I had to use vba, would it be easier?
Yes. You could use this Worksheet_Change event code in Sheet1. To implement ..
1. Right click the Sheet 1 name tab and choose "View Code".
2. Copy and Paste the code below into the main right hand pane that opens at step 1.
3. Close the Visual Basic window & test by entering data into Sheet1.
4. Your workbook will need to be saved as a macro-enabled workbook (*.xlsm).

VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
  Dim Changed As Range, c As Range
  
  Set Changed = Intersect(Target.EntireRow, Columns("A"))
  If Not Changed Is Nothing Then
    With Sheets("Sheet2").UsedRange
      For Each c In Changed
        If Not IsEmpty(c.Value) And Not IsEmpty(c.Offset(, 2).Value) Then .Replace What:=c.Value, Replacement:=c.Offset(, 2).Value, LookAt:=xlWhole
      Next c
    End With
  End If
End Sub
 
Last edited:
Upvote 0
Note that I edited my previous post so make sure that you have refreshed the page so have the latest version.
And please test with a copy of your workbook.
 
Upvote 0
Note that I edited my previous post so make sure that you have refreshed the page so have the latest version.
And please test with a copy of your workbook.
Wonderful, am gonna give it a try. Thank you so much for your help.
 
Upvote 0

Forum statistics

Threads
1,214,792
Messages
6,121,612
Members
449,039
Latest member
Mbone Mathonsi

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