Substituting Values from a list

av3ng3r85

Board Regular
Joined
Nov 17, 2006
Messages
60
Master List:

AA1/AB1-Bailey
AA2/AB2-Johnson
AA3/AB3-Madison

JA1/JB1-Parker
JA2/JB2-Evans
JA3/JB3-Metz

MA1/MB1-Hill
MA2/MB2-Reynolds
MA3/MB3-Sanders

I run a report that generates a list like this:

view


I need a way to convert the AA1,AA2,etc. in column B1 to the names they represent, when I paste my report in. The values in B1 vary each time the report is ran and there are 2 values for each name so I need it to always resolve to the right name.If anybody has any ideas,like a macro or formula,it would be greatly appreciated.
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
av3ng3r85

Welcome to the Mr Excel board!

You may need to clarify this a bit more.
I run a report that ...
Can you detail this procedure?
... when I paste my report in
Where does the report come from? How is it pasted (manual/Excel macro/something else)?
there are 2 values for each name so I need it to always resolve to the right name
Do you mean you need to replace AA1 and/or AB1 with Bailey etc?

By the way have you explored using Colo's HTML Maker for showing your sheet sample on this board? It's easier for us than tracking to another site. It also allows us to copy the sample and/or formulas from your sample to our sheets. Here's how to do it:
http://www.mrexcel.com/board2/viewtopic.php?t=92622
 
Upvote 0
The report runs a macro in another program that dumps information into a CSV file.The CSV file looks like this:
Book1.xls
ABCD
1AA1103.680068%
2AB291.2149050%
3AA376.5460022%
4JA156.4100085%
5JB266.0790011%
6JB373.31030012%
7MB191.9212005%
8MA286.1227001%
9MB392.2164032%
Sheet2


I paste that information in the appropriate places in a separate xls file that looks like this.
Book1.xls
ABCDEF
1GroupsValue1Value2Value3
2Region1
3
4
5
6
7Region2
8
9
10
11
12Region3
13
14
15
16
17
Sheet1


When I paste the values in I want some way for them to be able to be changed from AA1 or MB3 to human readable names like Bailey or Sanders.Thanks for your prompt response.If you need any more clarification, please just ask.
 
Upvote 0
More clarification...

The intermediate product looks like this,after I've pasted the data from the csv file into the appropriate spots on the xls file.(I had to move some columns around so it doesn't look exactly like what I posted last time.)
Book1.xls
ABCDE
1Value1Value2Value3
2Region1
3AA1103.680068%
4AB291.2149050%
5AA376.5460022%
6
7Region2
8JA156.4100085%
9JB266.0790011%
10JB373.31030012%
11
12Region3
13MB191.9212005%
14MA286.1227001%
15MB392.2164032%
Sheet1



And this is what I want the finished product to look like.Normally to achieve this result I have to manually type in the names but I would like a way to automatically convert the alpahanumeric group values to actual names.
Book1.xls
ABCDE
1Value1Value2Value3
2Region1
3Bailey103.680068%
4Johnson91.2149050%
5Madison76.5460022%
6
7Region2
8Parker56.4100085%
9Evans66.0790011%
10Metz73.31030012%
11
12Region3
13Hill91.9212005%
14Reynolds86.1227001%
15Sanders92.2164032%
Sheet3


Hope this further clears up some things.
 
Upvote 0
First put your lookup data in a sheet called Data.
Start at cells A1 and B1:
AA1 Bailey
AB1 Johnson
etc.

Then, in cell A3 type this formula and copy down:
=VLOOKUP(B3,Data!$A$1:$B$500,2,FALSE)
This should produce a list of the desired names.

Then just copy column A values to column B, and
Edit - Paste Special - Values to remove the formulas.
 
Upvote 0
Master List:

AA1/AB1-Bailey
AA2/AB2-Johnson
AA3/AB3-Madison

JA1/JB1-Parker
JA2/JB2-Evans
JA3/JB3-Metz

MA1/MB1-Hill
MA2/MB2-Reynolds
MA3/MB3-Sanders

In response to jindon, this is the list that I derive the group codes to name associations from.

larrydunn,this is a awesome start. :-D However when there is no value in the B2 column it displays N/A in the A column. Is there a way to just display a blank when there is no value in the B column. Let me see if I can show you what I mean.
Book1.xls
ABCDE
2Region1
3#N/A103.680068%
4JohnsonAB291.2149050%
5MadisonAA376.5460022%
6
7Region2
8ParkerJA156.4100085%
9EvansJB266.0790011%
10MetzJB373.31030012%
11
12Region3
13HillMB191.9212005%
14ReynoldsMA286.1227001%
15SandersMB392.2164032%
Sheet1


Also, is there a way to lock and hide the sheet called Data,to prevent tampering and make the report look cleaner.Thanks.
 
Upvote 0
This is the Data sheet where the group codes and names are associated.
Book1.xls
ABCDE
1AA1Bailey
2AB1Bailey
3AA2Johnson
4AB2Johnson
5AA3Madison
6AB3Madison
7JA1Parker
8JB1Parker
9JA2Evans
10JB2Evans
11JA3Metz
12JB3Metz
13MA1Hill
14MB1Hill
15MA2Reynolds
16MB2Reynolds
17MA3Sanders
18MB3Sanders
Data
 
Upvote 0
OK
here's a vba code, if you like...
Code:
Sub test()
Dim a, i As Long, dic As Object
Set dic = CreateObject("Scripting.Dictionary")
dic.CompareMode=vbTextCompare
With Sheets("data")
    a = .Range("a1",.Range("a" & Rows.Count).End(xlUp)).Resize(,2).Value
    .Visible = xlVeryHidden
End With
For i = 1 To UBound(a,1)
    If Not IsEmpty(a(i,1)) And Not dic.exists(a(i,1)) Then dic.add a(i,1), a(i,2)
Next
With Sheets("sheet1").Range("b2",.Range("b" & Rows.Count).End(xlUp))
    a = .Value
    For i = 1 To UBound(a,1)
        If dic.exists(a(i,1)) Then a(i,1) = dic(a(i,1))
    Next
    .Value = a
End With
Set dic = Nothing
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,542
Messages
6,179,421
Members
452,913
Latest member
JWD210

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