Formula Too Long

saffo5

New Member
Joined
Jul 27, 2019
Messages
1
Hi,

I am quite new on Excel and I am trying to create a Formula which is some kind of a database. I want to create an autofill of time between 2 locations that I will pre-set... In the first line for ex. IST is city code and BKK is city code, if I insert these 2 city codes the value of 2 hours and 10 minutes will automatically be filled.
My formula contains around 300 lines such as below, and when I finally tried to insert it, it says that formula is too long.

Do you have any idea to achieve this or bypass the formula is too long problem.

Many thanks.

Code:
=IF(AND(C2="IST",E2="BKK"),TIME(2,10,0),
IF(AND(C2="BKK",E2="IST"),TIME(5,35,0),
IF(AND(C2="FRA",E2="AYT"),TIME(3,35,0),
IF(AND(C2="MNS",E2="FRA"),TIME(2,40,0),
IF(AND(C2="BRU",E2="PAR"),TIME(2,30,0),
IF(AND(C2="JFK",E2="DCD"),TIME(3,45,0),
IF(AND(C2="SXD",E2="DKI"),TIME(3,25,0),
IF(AND(C2="ERD",E2="FDD"),TIME(2,35,0)
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
Hi,

I do not know your data structure but ...
In columns A and B put the names of the airports and in column C put the related times.

In F1 put a name, from column A, in G1 put a name, from column B (in the same row as the one from column A), and in
H1 put the formula:
= SUMPRODUCT ((A1: A8 = F1) * (B1: B8 = G1) * (C1: C8)), obviously increases the range of data as needed (A1: A300, B1: B300 ...)
 
Upvote 0
Hi, and welcome to Mr. Excel!
Likewise, I wouldn't try to use a huge formula for this; I was thinking of making a table on a separate worksheet, with the city codes along the top row, and down the first column, then populating all the associated journey times at each intersection. It'll take a but of effort, but no more than typing out your Loooong formula!
Then, on your main worksheet where you want the result to appear, have two cells - one for each city, and a formula in a 3rd cell to find the intersecting journey time.
 
Upvote 0
I was just playing around with this.
I started a new sheet, and put this mini table into A1:G7:

CCT BBA TYR YTP GVW ABQ
CCT - 65 12 3 5 4
BBA 800 - 24 31 0 5
TYR 1 2 - 4 5 6
YTP 25 2698 4523 - 125 389
GVW 3 213 5 658 - 8
ABQ 4 78 6 66 200 -

In K7:L8 I put this (where L7 holds a data validation list populated from B1:G1, and similarly in L8 - populated from A2:A7):
City BBA
City YTP

Then in a "Result" cell, formula:
=INDIRECT(ADDRESS(MATCH(L8,A2:A10,0)+1,MATCH(L7,B1:G1,0)+1))

Works well!
The data validation list just enables a drop-down list of allowed values, but isn't necessary.
 
Upvote 0
Another option without volatile functions.


Book1
ABCDEFGHIJKLMNOPQ
1ISTBKKFRAAYTMNSBRUPARJFKDCDSXDDKIERDFDDBKK
2IST05:3506:3507:3508:3509:3510:3511:3512:3513:3514:3515:3516:35IST05:35:00
3BKK02:1007:3508:3509:3510:3511:3512:3513:3514:3515:3516:3517:35
4FRA03:1007:3509:3510:3511:3512:3513:3514:3515:3516:3517:3518:35
5AYT04:1008:3509:3511:3512:3513:3514:3515:3516:3517:3518:3519:35
6MNS05:1009:3510:3511:3513:3514:3515:3516:3517:3518:3519:3520:35
7BRU06:1010:3511:3512:3513:3515:3516:3517:3518:3519:3520:3521:35
8PAR07:1011:3512:3513:3514:3515:3517:3518:3519:3520:3521:3522:35
9JFK08:1012:3513:3514:3515:3516:3517:3519:3520:3521:3522:3523:35
10DCD09:1013:3514:3515:3516:3517:3518:3519:3521:3522:3523:3500:35
11SXD10:1014:3515:3516:3517:3518:3519:3520:3521:3523:3500:3501:35
12DKI11:1015:3516:3517:3518:3519:3520:3521:3522:3523:3501:3502:35
13ERD12:1016:3517:3518:3519:3520:3521:3522:3523:3500:3501:3503:35
14FDD13:1017:3518:3519:3520:3521:3522:3523:3500:3501:3502:3503:35
Log
Cell Formulas
RangeFormula
Q2=INDEX(B2:N14,MATCH(P2,A2:A14,0),MATCH(P1,B1:N1,0))
 
Upvote 0
Having (finally) just got 'round to trying out the HTML maker, I thought I'd put it to its first bit of good use, so here's a better representation of my solution:


Book1
ABCDEFG
1CCTBBATYRYTPGVWABQ
2CCT-01:5302:4800:5202:5400:17
3BBA01:53-03:0201:0102:5801:49
4TYR02:4803:02-02:2003:0201:15
5YTP00:5201:0102:20-02:0200:38
6GVW02:5402:5803:0202:02-02:25
7ABQ00:1701:4901:1500:3802:25-
8
9From:GVW
10To:TYR
11Result:3:02
Sheet2
Cell Formulas
RangeFormula
C11=INDIRECT(ADDRESS(MATCH(C10,A2:A10,0)+1,MATCH(C9,B1:G1,0)+1))
 
Upvote 0
@saffo5
Did any of these suggestions help you?
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,284
Members
452,630
Latest member
OdubiYouth

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