PDA

View Full Version : VBA Needed? Auto populate cells with hard-coded value



khertz
08-04-2011, 07:28 AM
Hey everyone!

I need some help here with Excel 2007, the scenario is like this. I have 2 different excel file, where I should map it into one hence I have a set of values for example:

0001 = Pajamas
0002 = Sweater
0003 = T-Shirt
0004 = Jacket
0005 = Hat

In my file(A), my values are Pajamas, Sweater and etc. where in a separate file I have values 0001 = Pajamas, 0002 = Sweater, 0003 = T-Shirt and etc. Is there a way, I can hard-code the values in my file (A) to auto populate the numbers if its Pajamas, then auto-populate '0001' next to the cell.

I'm pretty new to excel and vba, but I'm happy to hear ideas to go around this and help would be very much appreciated! Thanks

Bob Phillips
08-04-2011, 08:38 AM
It is possible, but can we see the workbooks, to be sure of the data structures.

khertz
08-05-2011, 07:31 AM
Hey! Sorry for the late reply but basically, I have 2 workbooks to work with but it only allows me to upload one though :( Nevertheless, if you open the workbook, look at the column R, S, T, U

I have another workbook, with these values and I would like map it accordingly to column, for example column R = TTP11, so I wish to add a column next to it with the value "Agapanthus", which pushes S to T and so on. Is that possible?
TTP11 = Agapanthus

Bob Phillips
08-06-2011, 12:22 AM
Shame about the other one, but would it not just be

=VLOOKUP(R2,'[other workbook.xls]Sheet1'!$A:$C,2,FALSE)

etc.

khertz
08-06-2011, 12:37 AM
Alright, posted the second workbook, basically if my column R in first workbook matches with column C in my second workbook, then I want it to create a new column next to R which is S, to paste column D (information).

Hope it's not confusing :think:

Bob Phillips
08-06-2011, 01:20 AM
Can you post the second workbook now then?

khertz
08-06-2011, 01:24 AM
Alright, edited my second post with updated information.

Bob Phillips
08-07-2011, 04:51 AM
This works fine for me

=VLOOKUP(R2,[Book2.xlsx]Sheet1!$C:$E,2,FALSE)