IF Formula (possibly) or VBA

PinkUnicorn

New Member
Joined
Dec 12, 2017
Messages
30
Hi, I wonder if someone can help. I need to write either a long IF formula or maybe VBA – I’m just not sure!

I have a spreadsheet with a number of columns and rows and I need to pick up data from a separate sheet in the workbook depending on the information in specific cells.

So in row I there are four options of entry – these are MAJ, SSX, SER or VOL.

Depending on what shows in that row I need excel to my sheet called OUTCOME CODES and pick a specific cell and enter the text from that cell into the original sheet (the sheet that shows the MAJ, SSX, SER or VOL).

The cell which is selected will change depending on which column I am now filling in on the main spreadsheet

TABLES BELOW SHOWING THE DATA ON THE DIFFERENT SHEETS

[TABLE="width: 614"]
<tbody>[TR]
[TD]
[/TD]
[TD]E
[/TD]
[TD]F
[/TD]
[TD]G
[/TD]
[TD]H
[/TD]
[TD]I
[/TD]
[TD]J
[/TD]
[TD]K
[/TD]
[TD]L
[/TD]
[/TR]
[TR]
[TD]1
[/TD]
[TD]XXX
[/TD]
[TD]XXXX
[/TD]
[TD]XXX
[/TD]
[TD]XXX
[/TD]
[TD][/TD]
[TD]B1
[/TD]
[TD]B1
[/TD]
[TD]B2
[/TD]
[/TR]
[TR]
[TD]2
[/TD]
[TD]09183
[/TD]
[TD]11407
[/TD]
[TD]AB13001
[/TD]
[TD]3
[/TD]
[TD]VOL
[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]3
[/TD]
[TD]09802
[/TD]
[TD]U/K
[/TD]
[TD][/TD]
[TD]3
[/TD]
[TD]VOL
[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]4
[/TD]
[TD]09803
[/TD]
[TD]13109
[/TD]
[TD]AC02016
[/TD]
[TD]3
[/TD]
[TD]VOL
[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]5
[/TD]
[TD]09934
[/TD]
[TD]9994
[/TD]
[TD]AC95001
[/TD]
[TD]3
[/TD]
[TD]VOL
[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]6
[/TD]
[TD]09935
[/TD]
[TD]9995
[/TD]
[TD]AC95002
[/TD]
[TD]3
[/TD]
[TD]VOL
[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]7
[/TD]
[TD]08913
[/TD]
[TD]12099
[/TD]
[TD]AF15003
[/TD]
[TD]3
[/TD]
[TD]VOL
[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]8
[/TD]
[TD]07817
[/TD]
[TD]6300
[/TD]
[TD]AI04001
[/TD]
[TD]3
[/TD]
[TD]VOL
[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]9
[/TD]
[TD]07818
[/TD]
[TD]6301
[/TD]
[TD]AI04002
[/TD]
[TD]3
[/TD]
[TD]VOL
[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]




So, for example – the formula I need in N2 (under the heading of code B1) is where I need excel to look in I2 and see if it says MAJ, SSX, SER or VOL. And then go to the Outcome Codes sheet (below). If I2 says MAJ then it would enter the text from D8 (which is the relevant information for a B1 outcome code for a MAJ type). If I2 says VOL (as it does in the example) then excel would select the text from G8

[TABLE="width: 650"]
<tbody>[TR]
[TD]
[/TD]
[TD]A
[/TD]
[TD]B
[/TD]
[TD]C
[/TD]
[TD]D
[/TD]
[TD]E
[/TD]
[TD]F
[/TD]
[TD]G
[/TD]
[/TR]
[TR]
[TD]1
[/TD]
[TD]Filing Code
[/TD]
[TD]Definition
[/TD]
[TD]
[/TD]
[TD]MAJ
[/TD]
[TD]SSX
[/TD]
[TD]SER
[/TD]
[TD]VOL
[/TD]
[/TR]
[TR]
[TD]2

[/TD]
[TD]B1
[/TD]
[TD]EXAMPLE 1
[/TD]
[TD]
[/TD]
[TD]TEXT 1
[/TD]
[TD]TEXT 2
[/TD]
[TD]TEXT 3
[/TD]
[TD]TEXT 4
[/TD]
[/TR]
[TR]
[TD]3
[/TD]
[TD]B2
[/TD]
[TD]EXAMPLE 2
[/TD]
[TD]
[/TD]
[TD]TEXT 5
[/TD]
[TD]TEXT 6
[/TD]
[TD]TEXT 7
[/TD]
[TD]TEXT 8
[/TD]
[/TR]
[TR]
[TD]4
[/TD]
[TD]B5
[/TD]
[TD]EXAMPLE 3
[/TD]
[TD]
[/TD]
[TD]TEXT 9
[/TD]
[TD]TEXT 10
[/TD]
[TD]TEXT 11
[/TD]
[TD]TEXT 12
[/TD]
[/TR]
</tbody>[/TABLE]
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
With sheet1 like


Book1
ABCDEFG
1Filing CodeDefinitionMAJSSXSERVOL
2B1EXAMPLE 1TEXT 1TEXT 2TEXT 3TEXT 4
3B2EXAMPLE 2TEXT 5TEXT 6TEXT 7TEXT 8
4B5EXAMPLE 3TEXT 9TEXT 10TEXT 11TEXT 12
Sheet1


How about

Book1
EFGHIJKL
2XXXXXXXXXXXXXB1B1B2
3918311407AB130013VOLTEXT 4TEXT 4TEXT 8
49802U/K3VOLTEXT 4TEXT 4TEXT 8
5980313109AC020163VOLTEXT 4TEXT 4TEXT 8
699349994AC950013MAJTEXT 1TEXT 1TEXT 5
799359995AC950023SSXTEXT 2TEXT 2TEXT 6
8891312099AF150033SERTEXT 3TEXT 3TEXT 7
978176300AI040013VOLTEXT 4TEXT 4TEXT 8
1078186301AI040023VOLTEXT 4TEXT 4TEXT 8
Sheet2
Cell Formulas
RangeFormula
J3=INDEX(Sheet1!$D$2:$G$4,MATCH(J$2,Sheet1!$A$2:$A$4,0),MATCH($I3,Sheet1!$D$1:$G$1,0))
 
Upvote 0
You're welcome & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,224,824
Messages
6,181,187
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

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