IF with multiple conditions

samuelmaiia

New Member
Joined
Jul 21, 2019
Messages
1
Hi there,

Maybe someone can help me (is there any video/page I can watch?) as I am struggling to accomplish the following:


I have a huge list with post codes:
DN9 2BT
IP28 8PQ
DT6 4NG
F94 TP9N
LL20 8DD
RH1 2NB
YO22 5NH
TA8 2NZ
B48 7SQ
LL58 8YL


In the second column I want to insert a if statement (or other) that meets the following criteria,

If starts with,



[TABLE="width: 341"]
<tbody>[TR]
[TD]john[/TD]
[TD]pedro[/TD]
[TD]alex[/TD]
[/TR]
[TR]
[TD]CA[/TD]
[TD]LL[/TD]
[TD]SY[/TD]
[/TR]
[TR]
[TD]LA[/TD]
[TD]CH[/TD]
[TD]TF[/TD]
[/TR]
[TR]
[TD]BD[/TD]
[TD]CW[/TD]
[TD]WV[/TD]
[/TR]
[TR]
[TD]PR[/TD]
[TD]WN[/TD]
[TD]DY[/TD]
[/TR]
[TR]
[TD]BB[/TD]
[TD]WA[/TD]
[TD]WR[/TD]
[/TR]
[TR]
[TD]BL[/TD]
[TD]SK[/TD]
[TD]WS[/TD]
[/TR]
[TR]
[TD]OL[/TD]
[TD]IM[/TD]
[TD]DE[/TD]
[/TR]
[TR]
[TD]HX[/TD]
[TD][/TD]
[TD]NG[/TD]
[/TR]
[TR]
[TD]HD[/TD]
[TD][/TD]
[TD]LN[/TD]
[/TR]
[TR]
[TD]FY[/TD]
[TD][/TD]
[TD]LE[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD]NN[/TD]
[/TR]
[TR]
[TD]Any ideas?


Thank you[/TD]
[TD][/TD]
[TD]CV
[/TD]
[/TR]
</tbody>[/TABLE]
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
Re-posted
 
Last edited by a moderator:
Upvote 0
Hi - I might be able to help!

Can I clarify exactly what you are trying to do, you have your long list of postcodes, do you want them to be placed under the headings of the names?
 
Upvote 0
Let's try post#2 again!

Assuming that you can ALWAYS identify postcode to name with 2 leftmost characters

Maintain ONE list

Excel 2016 (Windows) 32 bit
[Table="width:, class:head"][tr=bgcolor:#E0E0F0][th] [/th][th]
A
[/th][th]
B
[/th][/tr]
[tr=bgcolor:#FFFFFF][td=bgcolor:#E0E0F0]
1
[/td][td]2 first
characters
of PostCode
[/td][td]Name[/td][/tr]

[tr=bgcolor:#FFFFFF][td=bgcolor:#E0E0F0]
2
[/td][td]CA[/td][td]john[/td][/tr]

[tr=bgcolor:#FFFFFF][td=bgcolor:#E0E0F0]
3
[/td][td]LA[/td][td]john[/td][/tr]

[tr=bgcolor:#FFFFFF][td=bgcolor:#E0E0F0]
4
[/td][td]BD[/td][td]john[/td][/tr]

[tr=bgcolor:#FFFFFF][td=bgcolor:#E0E0F0]
5
[/td][td]PR[/td][td]john[/td][/tr]

[tr=bgcolor:#FFFFFF][td=bgcolor:#E0E0F0]
6
[/td][td]BB[/td][td]john[/td][/tr]

[tr=bgcolor:#FFFFFF][td=bgcolor:#E0E0F0]
7
[/td][td]BL[/td][td]john[/td][/tr]

[tr=bgcolor:#FFFFFF][td=bgcolor:#E0E0F0]
8
[/td][td]OL[/td][td]john[/td][/tr]

[tr=bgcolor:#FFFFFF][td=bgcolor:#E0E0F0]
9
[/td][td]HX[/td][td]john[/td][/tr]

[tr=bgcolor:#FFFFFF][td=bgcolor:#E0E0F0]
10
[/td][td]HD[/td][td]john[/td][/tr]

[tr=bgcolor:#FFFFFF][td=bgcolor:#E0E0F0]
11
[/td][td]FY[/td][td]john[/td][/tr]

[tr=bgcolor:#FFFFFF][td=bgcolor:#E0E0F0]
12
[/td][td]LL[/td][td]pedro[/td][/tr]

[tr=bgcolor:#FFFFFF][td=bgcolor:#E0E0F0]
13
[/td][td]CH[/td][td]pedro[/td][/tr]

[tr=bgcolor:#FFFFFF][td=bgcolor:#E0E0F0]
14
[/td][td]CW[/td][td]pedro[/td][/tr]

[tr=bgcolor:#FFFFFF][td=bgcolor:#E0E0F0]
15
[/td][td]WN[/td][td]pedro[/td][/tr]

[tr=bgcolor:#FFFFFF][td=bgcolor:#E0E0F0]
16
[/td][td]WA[/td][td]pedro[/td][/tr]

[tr=bgcolor:#FFFFFF][td=bgcolor:#E0E0F0]
17
[/td][td]SK[/td][td]pedro[/td][/tr]

[tr=bgcolor:#FFFFFF][td=bgcolor:#E0E0F0]
18
[/td][td]IM[/td][td]pedro[/td][/tr]

[tr=bgcolor:#FFFFFF][td=bgcolor:#E0E0F0]
19
[/td][td]SY[/td][td]alex[/td][/tr]

[tr=bgcolor:#FFFFFF][td=bgcolor:#E0E0F0]
20
[/td][td]TF[/td][td]alex[/td][/tr]

[tr=bgcolor:#FFFFFF][td=bgcolor:#E0E0F0]
21
[/td][td]WV[/td][td]alex[/td][/tr]

[tr=bgcolor:#FFFFFF][td=bgcolor:#E0E0F0]
22
[/td][td]DY[/td][td]alex[/td][/tr]

[tr=bgcolor:#FFFFFF][td=bgcolor:#E0E0F0]
23
[/td][td]WR[/td][td]alex[/td][/tr]

[tr=bgcolor:#FFFFFF][td=bgcolor:#E0E0F0]
24
[/td][td]WS[/td][td]alex[/td][/tr]

[tr=bgcolor:#FFFFFF][td=bgcolor:#E0E0F0]
25
[/td][td]DE[/td][td]alex[/td][/tr]

[tr=bgcolor:#FFFFFF][td=bgcolor:#E0E0F0]
26
[/td][td]NG[/td][td]alex[/td][/tr]

[tr=bgcolor:#FFFFFF][td=bgcolor:#E0E0F0]
27
[/td][td]LN[/td][td]alex[/td][/tr]

[tr=bgcolor:#FFFFFF][td=bgcolor:#E0E0F0]
28
[/td][td]LE[/td][td]alex[/td][/tr]

[tr=bgcolor:#FFFFFF][td=bgcolor:#E0E0F0]
29
[/td][td]NN[/td][td]alex[/td][/tr]

[tr=bgcolor:#FFFFFF][td=bgcolor:#E0E0F0]
30
[/td][td]CV[/td][td]alex[/td][/tr]

[tr=bgcolor:#FFFFFF][td=bgcolor:#E0E0F0]
31
[/td][td][/td][td][/td][/tr]
[/table]
[Table="width:, class:grid"][tr][td]Sheet: Sheet2[/td][/tr][/table]

And use VLOOKUP

Excel 2016 (Windows) 32 bit
[Table="width:, class:head"][tr=bgcolor:#E0E0F0][th] [/th][th]
A
[/th][th]
B
[/th][th]
C
[/th][/tr]
[tr=bgcolor:#FFFFFF][td=bgcolor:#E0E0F0]
1
[/td][td]PostCodes[/td][td]Name[/td][td] Formula in B2 copied down[/td][/tr]

[tr=bgcolor:#FFFFFF][td=bgcolor:#E0E0F0]
2
[/td][td]DN9 2BT[/td][td][/td][td] =IFERROR(VLOOKUP(LEFT(A2,2),Sheet2!A:B,2,0),"")[/td][/tr]

[tr=bgcolor:#FFFFFF][td=bgcolor:#E0E0F0]
3
[/td][td]IP28 8PQ[/td][td][/td][td][/td][/tr]

[tr=bgcolor:#FFFFFF][td=bgcolor:#E0E0F0]
4
[/td][td]DT6 4NG[/td][td][/td][td][/td][/tr]

[tr=bgcolor:#FFFFFF][td=bgcolor:#E0E0F0]
5
[/td][td]F94 TP9N[/td][td][/td][td][/td][/tr]

[tr=bgcolor:#FFFFFF][td=bgcolor:#E0E0F0]
6
[/td][td]LL20 8DD[/td][td]pedro[/td][td][/td][/tr]

[tr=bgcolor:#FFFFFF][td=bgcolor:#E0E0F0]
7
[/td][td]RH1 2NB[/td][td][/td][td][/td][/tr]

[tr=bgcolor:#FFFFFF][td=bgcolor:#E0E0F0]
8
[/td][td]YO22 5NH[/td][td][/td][td][/td][/tr]

[tr=bgcolor:#FFFFFF][td=bgcolor:#E0E0F0]
9
[/td][td]TA8 2NZ[/td][td][/td][td][/td][/tr]

[tr=bgcolor:#FFFFFF][td=bgcolor:#E0E0F0]
10
[/td][td]B48 7SQ[/td][td][/td][td][/td][/tr]

[tr=bgcolor:#FFFFFF][td=bgcolor:#E0E0F0]
11
[/td][td]LL58 8YL[/td][td]pedro[/td][td][/td][/tr]
[/table]
[Table="width:, class:grid"][tr][td]Sheet: Sheet1[/td][/tr][/table]
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,175
Members
453,021
Latest member
Justyna P

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