IF Formula (possibly) or VBA

PinkUnicorn

New Member
Joined
Dec 12, 2017
Messages
28
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


E
F
G
H
I
J
K
L
1
XXX
XXXX
XXX
XXX
B1
B1
B2
2
09183
11407
AB13001
3
VOL
3
09802
U/K
3
VOL
4
09803
13109
AC02016
3
VOL
5
09934
9994
AC95001
3
VOL
6
09935
9995
AC95002
3
VOL
7
08913
12099
AF15003
3
VOL
8
07817
6300
AI04001
3
VOL
9
07818
6301
AI04002
3
VOL

<tbody>
</tbody>




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


A
B
C
D
E
F
G
1
Filing Code
Definition

MAJ
SSX
SER
VOL
2

B1
EXAMPLE 1

TEXT 1
TEXT 2
TEXT 3
TEXT 4
3
B2
EXAMPLE 2

TEXT 5
TEXT 6
TEXT 7
TEXT 8
4
B5
EXAMPLE 3

TEXT 9
TEXT 10
TEXT 11
TEXT 12

<tbody>
</tbody>
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
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,214,786
Messages
6,121,553
Members
449,038
Latest member
Guest1337

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