Forum Discussion
Juggling items from one column to it's corresponding row in a new column
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
- Riny_van_EekelenPlatinum Contributor
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.
- Robert_PeltzmanCopper ContributorWow, thanks, I'll correct those errors and give it a try!
Robert
- bosinanderIron Contributor
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.
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_PeltzmanCopper ContributorThanks Bos. This gives some options to play with.
- Robert_PeltzmanCopper ContributorBefore 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?