Formula to auto fill a name

UMAKEMESIK

Active Member
Joined
Oct 3, 2005
Messages
378
I am reposting an old post in which I tried to use but does not work

am I doing something wrong.

below is the original post:

-----------------------
Here is a Vba solution:

If you will be entering all your values in column "A" for example use this:

Put a list of your shortened values like "Ja" for January into column "E" starting in row(1) and as far down as you like.

And in column "F" adjacent to "Ja" put the full value like "January"

Now any time you enter "Ja" in column "A" the value will be changed to "January"

You can modify this script to include columns A to C or what ever you want. And you can modify the columns with your shortened and full text values if you want.

This is an auto sheet event script
Your Workbook must be Macro enabled
To install this code:
Right-click on the sheet tab
Select View Code from the pop-up context menu
Paste the code in the VBA edit window
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("A:A")) Is Nothing Then
If Target.Cells.Count > 1 Or IsEmpty(Target) Then Exit Sub
Application.EnableEvents = False
Dim c As Range
    For Each c In Range("E1:E" & Cells(Rows.Count, "E").End(xlUp).Row)
        If c.Value = Target.Value Then Target.Value = c.Offset(0, 1).Value
    Next
End If
Application.EnableEvents = True
End Sub

on my wb in inserted a module1
and put this in there.
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("B:B")) Is Nothing Then
If Target.Cells.Count > 1 Or IsEmpty(Target) Then Exit Sub
Application.EnableEvents = False
Dim c As Range
    For Each c In Range("P1:P" & Cells(Rows.Count, "P").End(xlUp).Row)
        If c.Value = Target.Value Then Target.Value = c.Offset(0, 1).Value
    Next
End If
Application.EnableEvents = True
End Sub


you will see on my frst sheet the rage is column b for the entry
and on my sheet I enter items in B2

I put the abbreviated list in p starting In p2
and the full name list in Q starting in Q2

and nothing happens.

anyhelp would be appreciated.
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
Hi,

What you have is a "Worksheet Change" event code, you need to insert the code in the "Worksheet" module in the sheet where you're entering data, Not a standard module as you described.

To install this code:
Right-click on the sheet tab
Select View Code from the pop-up context menu
Paste the code in the VBA edit window
 
Last edited:
Upvote 0
Hi,

What you have is a "Worksheet Change" event code, you need to insert the code in the "Worksheet" module in the sheet where you're entering data, Not a standard module as you described.



That was so simple to fix, thanks for pointing me in the right directions.

all works great now.

Have a good one.
 
Upvote 0

Forum statistics

Threads
1,223,889
Messages
6,175,226
Members
452,620
Latest member
dsubash

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