Juggling items from one column to it's corresponding row in a new column

%3CLINGO-SUB%20id%3D%22lingo-sub-3016276%22%20slang%3D%22en-US%22%3EJuggling%20items%20from%20one%20column%20to%20it's%20corresponding%20row%20in%20a%20new%20column%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3016276%22%20slang%3D%22en-US%22%3E%3CP%3EI've%20got%20an%20inventory%20list%20in%20column%20A%20of%20all%20my%20meds%20(about%20300).%20I've%20got%20a%20medication%20usage%20list%20in%20a%20different%20column%20(say%2C%20C)%20that%20only%20has%20the%20list%20of%20meds%20that%20I've%20dispensed%20in%20the%20last%20month%20(about%2090).%20If%20I%20can%20get%20each%20of%20the%20meds%20in%20the%20C%20column%20to%20appear%20on%20the%20same%20line%20as%20the%20corresponding%20drug%20in%20column%20A%2C%20I%20could%20easily%20subtract%20col.%20C%20from%20col.%20A%20to%20get%20my%20current%20inventory.%20Is%20there%20an%20easy%20way%20to%20do%20this%20without%20cutting%20and%20pasting%20each%20med%20from%20column%20C%20to%20it's%20correct%20line%20in%20a%20new%20column%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-3016276%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EFormulas%20and%20Functions%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-3016853%22%20slang%3D%22en-US%22%3ERe%3A%20Juggling%20items%20from%20one%20column%20to%20it's%20corresponding%20row%20in%20a%20new%20column%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3016853%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1233000%22%20target%3D%22_blank%22%3E%40Robert_Peltzman%3C%2FA%3E%26nbsp%3B%20Hi%2C%3C%2FP%3E%3CP%3EWith%20Excel%20365%20you%20can%26nbsp%3B%20have%20cell%20B1%3CBR%20%2F%3E%3DXLOOKUP(A1%3BC%3AC%3BD%3AD%3B%22%22)%3CBR%20%2F%3Ebeing%20similar%20to%20in%20older%20versions%20of%20Excel%2C%20use%3CBR%20%2F%3E%3DIFERROR(VLOOKUP(A1%3BC%3AD%3B2%3B0)%3B0)%3CBR%20%2F%3Eand%20in%20both%20cases%20fill%20down%20or.%3C%2FP%3E%3CP%3EEven%20better%2C%20select%20in%20column%20A%20an%20Insert%3Atable.%20Your%20formulas%20will%20then%20expand%20with%20the%20number%20of%20rows%20in%20the%20table.%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22bosinander_0-1638253817180.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F330274iC062EF91CE3137C8%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22bosinander_0-1638253817180.png%22%20alt%3D%22bosinander_0-1638253817180.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3EBoth%20columns%20Usage%20and%20Out%20are%20calculated.%3C%2FP%3E%3CP%3EBeware%20though%20that%20if%20you%20undo%20a%20change%20in%20a%20tables%20column%20formula%2C%20you%20may%20have%20to%20undo%20two%20or%20three%20times%20to%20come%20back%20to%20previous%20state.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-3016863%22%20slang%3D%22en-US%22%3ERe%3A%20Juggling%20items%20from%20one%20column%20to%20it's%20corresponding%20row%20in%20a%20new%20column%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3016863%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1233000%22%20target%3D%22_blank%22%3E%40Robert_Peltzman%3C%2FA%3E%26nbsp%3BThis%20would%20be%20something%20for%20VLOOKUP%20or%20XLOOKUP%20is%20your%20Excel%20version%20supports%20it.%20But%2C%20your%20data%20seems%20to%20be%20inconsistent.%20One%20med%20on%20the%20shorter%20list%20does%20not%20exist%20in%20the%20long%20list%20(marked%20yellow)%20and%20four%20meds%20on%20the%20short%20list%20seem%20to%20have%20different%20names%20(marked%20orange).%20For%20instance%2C%20%22GlipiZIDE%2010%20mg%20tablet%22%20vs.%20%22Glipizide%2010mg%20tablet%22.%20Either%20of%20the%20lookup%20functions%20will%20not%20match%20them.%20Then%20you%20have%20some%20double%20entries%20in%20the%20long%20list%2C%20also%20causing%20trouble.%26nbsp%3B%22Garbage%20in%2C%20garbage%20out%22.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI've%20reconciled%20the%20lists%20for%20you%20(using%20VLOOKUP%20as%20it%20works%20for%20all%20Excel%20versions)%2C%20trusting%20that%20it%20will%20enable%20you%20to%20clean-up%20the%20data%20yourself.%26nbsp%3B%3C%2FP%3E%3CP%3ESee%20attached%20file.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-3017022%22%20slang%3D%22en-US%22%3ERe%3A%20Juggling%20items%20from%20one%20column%20to%20it's%20corresponding%20row%20in%20a%20new%20column%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3017022%22%20slang%3D%22en-US%22%3EWow%2C%20thanks%2C%20I'll%20correct%20those%20errors%20and%20give%20it%20a%20try!%3CBR%20%2F%3ERobert%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-3017052%22%20slang%3D%22en-US%22%3ERe%3A%20Juggling%20items%20from%20one%20column%20to%20it's%20corresponding%20row%20in%20a%20new%20column%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3017052%22%20slang%3D%22en-US%22%3EThanks%20Bos.%20This%20gives%20some%20options%20to%20play%20with.%3C%2FLINGO-BODY%3E
Occasional Contributor

I've got an inventory list in column A of all my meds (about 300). I've got a medication usage list in a different column (say, C) that only has the list of meds that I've dispensed in the last month (about 90). If I can get each of the meds in the C column to appear on the same line as the corresponding drug in column A, I could easily subtract col. C from col. A to get my current inventory. Is there an easy way to do this without cutting and pasting each med from column C to it's correct line in a new column?

12 Replies

@Robert_Peltzman  Hi,

With Excel 365 you can  have cell B1
=XLOOKUP(A1;C:C;D:D;"")
being similar to in older versions of Excel, use
=IFERROR(VLOOKUP(A1;C:D;2;0);0)
and in both cases fill down or.

Even better, select in column A an Insert:table. Your formulas will then expand with the number of rows in the table.

bosinander_0-1638253817180.png

Both columns Usage and Out are calculated.

Beware though that if you undo a change in a tables column formula, you may have to undo two or three times to come back to previous state.

 

@Robert_Peltzman This would be something for VLOOKUP or XLOOKUP is your Excel version supports it. But, your data seems to be inconsistent. One med on the shorter list does not exist in the long list (marked yellow) and four meds on the short list seem to have different names (marked orange). For instance, "GlipiZIDE 10 mg tablet" vs. "Glipizide 10mg tablet". Either of the lookup functions will not match them. Then you have some double entries in the long list, also causing trouble. "Garbage in, garbage out".

 

I've reconciled the lists for you (using VLOOKUP as it works for all Excel versions), trusting that it will enable you to clean-up the data yourself. 

See attached file.

 

Wow, thanks, I'll correct those errors and give it a try!
Robert
Thanks Bos. This gives some options to play with.
Before I try some of those formulas, tomorrow, I've got one more question: The meds in column C all have numbers associated with then in col. D (not shown). After I move col. C, over, how do I reattach those numbers to the items in the new Col. B?

@Robert_Peltzman,

Mm... if you have the article numbers, use them instead of the names and you will get better results since it may happen that two different numbers share the same name.

Adjust the formulas to use the numbers;

D2    =IFERROR(VLOOKUP(A2;G:I;3;0);0)

bosinander_0-1638268045966.png

 

 

What I posted was just a small part of the spreadsheet, Darn, this looks better than my original.
Thank you!
I'm going to try that.
You're welcome.
Also, by using the article numbers/ID's even in the shorter list you will cut the risk of misspelling the names and thus miss or point wrong in the inventory list.
If you continue using names in the subscription/small list (that may be what you are used to since it is more handy), it will be a good idea to append also Riny van Eekelens formulas to see that you get an inventory match on the name.
My version of Excel doesn't like this formula =IFERROR(VLOOKUP(A2;G:I;3;0);0)
I've got Office Professional Plus 2019
Could that be the problem?
Also, what does the 3 do, in the formula? I know 1 and 2 have to do with matching exactly or closely.

@Robert_Peltzman 

I do not have the same national/local settings as you, and have semi colon where your version expects a comma.

Using the attached file should overcome that, or change ; to comma.

The parameter with 3 means column number three in the lookup area. It is though better to start using xlookup. It also has the parameter you refer to by default set to match exactly.

bosinander_1-1638290908969.png

 

(there seems to be an issue with attaching files - let me know if you need it another way)

bosinander_0-1638290867067.png