Display specific text based on a value within the same cell??

realsongs

New Member
Joined
Dec 18, 2018
Messages
9
Office Version
  1. 365
Platform
  1. Windows
Hi all,

Is it possbile to convert one text to another based on a set of values, all in the same cell???

For example, if I would like to type in an employees staff number is cell A1, and then for the text in cell A1 to display the corresponding staff members name.

I spent the past hour looking this up, and thought I came close with conditional formatting however the method I found doesn't seem to work.

Thank you in advance for looking!!!!

S
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
Excel 2010
ABCDEFGHI
FnameLname
PeterSmith
PaulLong
MaryParker

<tbody>
[TD="align: center"]1[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: center"]Emp#[/TD]

[TD="align: center"]2[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"]100[/TD]

[TD="align: center"]3[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"]200[/TD]

[TD="align: center"]4[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"]300[/TD]

[TD="align: center"]5[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]

</tbody>
Sheet1
Post the Code (below) into Sheet1 Module (as Event Code). This worked for me....
Type either 100, 200, or 300 into Cell A1 and Enter.

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column <> 1 Then Exit Sub
If Target.Value = "" Then Exit Sub
Application.ScreenUpdating = False
Application.EnableEvents = False
    OV = Target.Value
    Application.Undo
On Error Resume Next
Target.Value = WorksheetFunction.VLookup(OV, Range("$G$2:$I$4"), 2, False) & " " & WorksheetFunction.VLookup(OV, Range("$G$2:$I$4"), 3, False)
Application.ScreenUpdating = True
Application.EnableEvents = True
On Error GoTo 0
End Sub
 
Last edited:
Upvote 0
Many thanks for this, it worked perfectly.

I will modify the code to include a range of columns.

Thanks again!
 
Upvote 0
At Present you should be able to Fill multiple cells in Column A (A1,A2,A3,A4.....)
It close, but not perfect... Thanks for the response. Jim
 
Upvote 0

Forum statistics

Threads
1,224,820
Messages
6,181,157
Members
453,021
Latest member
Justyna P

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