Many many Q's - conditional formatting plus IF, VLOOKUP queries

lemmo80

New Member
Joined
Jun 10, 2021
Messages
5
Office Version
  1. 365
Platform
  1. Windows
Hi there,

Thank you in advance to anyone that can help, I have a lot of big ideas for my spreadsheet but limited knowledge of application. Firstly, some background, the data input into the sheet is a straight cut & transpose from a word table. Columns A:L are the cut & transposed data, the remaining columns are the working tools. I cannot add or remove any of columns A:L and any formulas written into them will be deleted when I transpose new data into the sheet, but I think conditional formatting might work? And yes, I feel like I'm over-asking, so please tell me if that's the case and I'll keep fumbling away with googling solutions.

So... to the list of queries: by column;

Column A, this is meant to be a mobile number, however the "0" drops off when transposed. Is there a conditional formatting formula that turns it into 0XXX XXX XXX?
Columns D:G are a duplication of H:K, this spilt occurs due to the response given in column C. I would like data from D:G to be replicated into H:K, I can then hide D:G so the data is more consolidated visually. Is this possible? I've tried doing basic "= & if blank, return blank" formulas, but again it gets deleted when I transpose new data.
Column M, this column is not effected by the transpose so a normal formula will stay. This column counts the days in transit. The formula works prefect when the transit is both ways, however I would like it to return "0" when its one-way. Currently the formula is written to work on H:K as I'm assuming the D:G replication is possible.
Column N, this works fine.
Column O, well.... this is a dozy and gold medal challenge...! the column calculates the charge rate depending on the length of the vehicle given in column B. The charge structure is E18:F26. Travel is charged per run, but if you travel both ways on the same day and on the same run you only get charged one-way. For example the booking on Row 2, will only get charged for one run ($465) as they travelled both ways on same day (28/7) and same run (blue, run 2). Whereas the booking on Row 3, needs to be charged twice ($255x2=$510), they travelled both ways on same day (3/8) but different runs (run 1, then run 2). All others both way bookings travelled different days so need to be charged twice. I've written a nested "IF(AND" that works great for one run charging BUT, now need it to "lookup" H:K (assuming D:G are replicated there) and say something like "IF H&J are MATCH (AND(IF I&K are MATCH, *1" .... "IF H&J are no MATCH, *2. Please note I&K will not match exactly as the loading time for each run is different. If this formula needs to be broken down over a few columns they can be added from R onwards or make more helper boxes below. so so sorry, I wish I could solve this on my own but I'm so out of my depth.
Column P, works fine.

That's it! What do you think... challenge accepted??

TEST VERSION - Jan - Jun 2021 - Truck Bookings Track ^0 Trace.xlsx
ABCDEFGHIJKLMNOP
1Contact NumberLength*Are you requesting to travel*Depart Sydney DATE OF TRAVEL Sydney Truck RunDepart Hazelbrook DATE OF TRAVELHazelbrook Truck RunDepart Sydney DATE OF TRAVEL Sydney Truck RunDepart Hazelbrook DATE OF TRAVELHazelbrook Truck RunTravel Category**NEW ** Day Counter**NEW MANUAL** TC Charge**NEW MANUAL** Truck Charge**NEW MANUAL** Total Amount $*
24426910106.5both ways (return)28/07/2021Blue Truck - Run 2, loading 10.30am28/07/2021Blue Truck - Run 2, loading 1.00pmOther Type11465466
34303525946both ways (return)3/08/2021Blue Truck - Run 1, loading 6.30am3/08/2021Blue Truck - Run 2, loading 1.00pmOther Type11255256
44582314305.3both ways (return)5/08/2021Blue Truck - Run 1, loading 6.30am6/08/2021Blue Truck - Run 2, loading 1.00pmRegular (GVM < 4.5 Tonne)210255265
54458930145.6both ways (return)28/07/2021Blue Truck - Run 1, loading 6.30am30/07/2021Blue Truck - Run 1, loading 9.00amOther Type33255258
64737718509.3both ways (return)28/07/2021Blue Truck - Run 1, loading 6.30am30/07/2021Blue Truck - Run 1, loading 9.00amHeavy (GVM > 4.5 Tonne)336465501
74614334349both ways (return)4/08/2021Blue Truck - Run 2, loading 10.30am6/08/2021Blue Truck - Run 1, loading 9.00amRegular (GVM < 4.5 Tonne)315465480
84893122709.9both ways (return)3/08/2021Blue Truck - Run 2, loading 10.30am6/08/2021Blue Truck - Run 2, loading 1.00pmHeavy (GVM > 4.5 Tonne)448780828
94288775797.5both ways (return)16/08/2021Blue Truck - Run 1, loading 6.30am19/08/2021Blue Truck - Run 2, loading 1.00pmRegular (GVM < 4.5 Tonne)420465485
1045675641511.2to Hazelbrook26/07/2021Red Truck - Run 1, Loading 8:00am1#N/A780780
114444179999to Hazelbrook26/07/2021Red Truck - Run 1, Loading 8:00am1#N/A465465
124722968358to Hazelbrook23/07/2021Blue Truck - Run 1, loading 6.30am1#N/A465465
134599584199to Sydney28/07/2021Blue Truck - Run 1, loading 9.00am1#N/A465465
144878372555.15to Sydney30/07/2021Blue Truck - Run 2, loading 1.00pm1#N/A255255
15
16
17HELPER CELLS BELOWHELPER CELLS BELOW
18MeteragePriceCHARGES MATRIXDAILY RATE
19Pallet110Regular (GVM < 4.5 Tonne)5
201.5 to 3.0m150Heavy (GVM > 4.5 Tonne)12
213.01 to 6.0m255Other Type1
226.01 to 9.5m465
239.51 to 12.5m780
2412.51 to 18m840
2518.1 to 23m890
26> 23m1005
Sheet1
Cell Formulas
RangeFormula
M2:M14M2=SUM(J2-H2)+1
N2:N14N2=VLOOKUP(L2,$I$18:$J$21,2,FALSE)*M2
O2:O14O2=IF(AND(B2<1.5),110,IF(AND(B2>1.49,B2<3.01),150,IF(AND(B2>3,B2<6.01),255,IF(AND(B2>6,B2<9.51),465,IF(AND(B2>9.5,B2<12.51),780,IF(AND(B2>12.5,B2<18.01),840,IF(AND(B2>23),1005,0)))))))
P2:P14P2=SUMIF(N2:O2,"<>#N/A")
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
The best approach depends on your skill level.
Ideally you want address how you are getting the data.
You say you are getting it from word but how is it getting into word, can you cut out that step and get a cleaner data source ?
Do you want to use VBA or Power Query ?

The simplest solution is to do it all using formulas.
You are already talking about hiding Columns D:G how about hiding all your current columns:
You would use the Data > Outline > Group function to hide all the columns on the left.
I would add an additional heading that says Input Section (do not use merge cells to do this or anywhere)
On the right side I would use a heading called Output Section.

You will need to convert the table that appears on the bottom left hand side to an Excel table and give a Table Name of tbl_Meterage
for the formulas to work.

If you decide this is the way to go you can in theory delete:
U:X and
M:P

20210811 Word To Excel Transpose Formulas etc.xlsx
ABCDEFGHIJKLMNOPQRSTUVWXYZAAABACADAEAFAGAHAI
1Contact NumberLength*Are you requesting to travel*Depart Sydney DATE OF TRAVEL Sydney Truck RunDepart Hazelbrook DATE OF TRAVELHazelbrook Truck RunDepart Sydney DATE OF TRAVEL Sydney Truck RunDepart Hazelbrook DATE OF TRAVELHazelbrook Truck RunTravel Category**NEW ** Day Counter**NEW MANUAL** TC Charge**NEW MANUAL** Truck Charge**NEW MANUAL** Total Amount $*Contact NumberLength*Are you requesting to travel*Depart Sydney DATE OF TRAVEL Sydney Truck RunDepart Hazelbrook DATE OF TRAVELHazelbrook Truck RunDepart Sydney DATE OF TRAVEL Sydney Truck RunDepart Hazelbrook DATE OF TRAVELHazelbrook Truck RunTravel Category**NEW ** Day Counter**NEW MANUAL** TC Charge**NEW MANUAL** Truck Charge**NEW MANUAL** Total Amount $***NEW MANUAL** Truck Charge MULTIPLIER
24426910106.5both ways (return)28/07/2021Blue Truck - Run 2, loading 10.30am28/07/2021Blue Truck - Run 2, loading 1.00pmOther Type114654664426910106.5both ways (return)28/07/2021Blue Truck - Run 2, loading 10.30am28/07/2021Blue Truck - Run 2, loading 1.00pmOther Type114654661
34303525946both ways (return)3/08/2021Blue Truck - Run 1, loading 6.30am3/08/2021Blue Truck - Run 2, loading 1.00pmOther Type112552564303525946both ways (return)3/08/2021Blue Truck - Run 1, loading 6.30am3/08/2021Blue Truck - Run 2, loading 1.00pmOther Type115105112
44582314305.3both ways (return)5/08/2021Blue Truck - Run 1, loading 6.30am6/08/2021Blue Truck - Run 2, loading 1.00pmRegular (GVM < 4.5 Tonne)2102552654582314305.3both ways (return)5/08/2021Blue Truck - Run 1, loading 6.30am6/08/2021Blue Truck - Run 2, loading 1.00pmRegular (GVM < 4.5 Tonne)2105105202
54458930145.6both ways (return)28/07/2021Blue Truck - Run 1, loading 6.30am30/07/2021Blue Truck - Run 1, loading 9.00amOther Type332552584458930145.6both ways (return)28/07/2021Blue Truck - Run 1, loading 6.30am30/07/2021Blue Truck - Run 1, loading 9.00amOther Type335105132
64737718509.3both ways (return)28/07/2021Blue Truck - Run 1, loading 6.30am30/07/2021Blue Truck - Run 1, loading 9.00amHeavy (GVM > 4.5 Tonne)3364655014737718509.3both ways (return)28/07/2021Blue Truck - Run 1, loading 6.30am30/07/2021Blue Truck - Run 1, loading 9.00amHeavy (GVM > 4.5 Tonne)3369309662
74614334349both ways (return)4/08/2021Blue Truck - Run 2, loading 10.30am6/08/2021Blue Truck - Run 1, loading 9.00amRegular (GVM < 4.5 Tonne)3154654804614334349both ways (return)4/08/2021Blue Truck - Run 2, loading 10.30am6/08/2021Blue Truck - Run 1, loading 9.00amRegular (GVM < 4.5 Tonne)3159309452
84893122709.9both ways (return)3/08/2021Blue Truck - Run 2, loading 10.30am6/08/2021Blue Truck - Run 2, loading 1.00pmHeavy (GVM > 4.5 Tonne)4487808284893122709.9both ways (return)3/08/2021Blue Truck - Run 2, loading 10.30am6/08/2021Blue Truck - Run 2, loading 1.00pmHeavy (GVM > 4.5 Tonne)448156016082
94288775797.5both ways (return)16/08/2021Blue Truck - Run 1, loading 6.30am19/08/2021Blue Truck - Run 2, loading 1.00pmRegular (GVM < 4.5 Tonne)4204654854288775797.5both ways (return)16/08/2021Blue Truck - Run 1, loading 6.30am19/08/2021Blue Truck - Run 2, loading 1.00pmRegular (GVM < 4.5 Tonne)4209309502
1045675641511.2to Hazelbrook26/07/2021Red Truck - Run 1, Loading 8:00am1#N/A78078045675641511.2to Hazelbrook26/07/2021Red Truck - Run 1, Loading 8:00am  00#N/A7807801
114444179999to Hazelbrook26/07/2021Red Truck - Run 1, Loading 8:00am1#N/A4654654444179999to Hazelbrook26/07/2021Red Truck - Run 1, Loading 8:00am  00#N/A4654651
124722968358to Hazelbrook23/07/2021Blue Truck - Run 1, loading 6.30am1#N/A4654654722968358to Hazelbrook23/07/2021Blue Truck - Run 1, loading 6.30am  00#N/A4654651
134599584199to Sydney28/07/2021Blue Truck - Run 1, loading 9.00am1#N/A4654654599584199to Sydney  28/07/2021Blue Truck - Run 1, loading 9.00am00#N/A4654651
144878372555.15to Sydney30/07/2021Blue Truck - Run 2, loading 1.00pm1#N/A2552554878372555.15to Sydney  30/07/2021Blue Truck - Run 2, loading 1.00pm00#N/A2552551
15
16
17Meterage FromMeterage ToPriceHELPER CELLS BELOW
181.53150CHARGES MATRIXDAILY RATE
193.016255Regular (GVM < 4.5 Tonne)5
206.019.5465Heavy (GVM > 4.5 Tonne)12
219.5112.5780Other Type1
2212.5118840
2318.123890
2423.11005
25Pallet
26
Data
Cell Formulas
RangeFormula
M2:M14M2=SUM(J2-H2)+1
N2:N14,AE2:AE14N2=VLOOKUP(L2,$I$18:$J$21,2,FALSE)*M2
O2:O14O2=IF(AND(B2<1.5),110,IF(AND(B2>1.49,B2<3.01),150,IF(AND(B2>3,B2<6.01),255,IF(AND(B2>6,B2<9.51),465,IF(AND(B2>9.5,B2<12.51),780,IF(AND(B2>12.5,B2<18.01),840,IF(AND(B2>23),1005,0)))))))
P2:P14,AG2:AG14P2=SUMIF(N2:O2,"<>#N/A")
R2:T14,AC2:AC14R2=A2
Y2:Z14Y2=IF($H2<>"",H2,IF($D2<>"",D2,""))
AA2:AB14AA2=IF($H2<>"",J2,IF($F2<>"",F2,""))
AD2:AD14AD2=IF(C2="both ways (return)",SUM(AA2-Y2)+1,0)
AF2:AF14AF2=VLOOKUP(S2,tbl_Meterage,3,TRUE)*AH2
AH2:AH14AH2=IF(AND(Y2<>"",AA2<>""), IF(Y2<>AA2, 2, IF(LEFT(Z2,FIND(",",Z2))<>LEFT(AB2,FIND(",",AB2)), 2, 1)), 1)
 
Upvote 0
Solution
The best approach depends on your skill level.
Ideally you want address how you are getting the data.
You say you are getting it from word but how is it getting into word, can you cut out that step and get a cleaner data source ?
Do you want to use VBA or Power Query ?

The simplest solution is to do it all using formulas.
You are already talking about hiding Columns D:G how about hiding all your current columns:
You would use the Data > Outline > Group function to hide all the columns on the left.
I would add an additional heading that says Input Section (do not use merge cells to do this or anywhere)
On the right side I would use a heading called Output Section.

You will need to convert the table that appears on the bottom left hand side to an Excel table and give a Table Name of tbl_Meterage
for the formulas to work.

If you decide this is the way to go you can in theory delete:
U:X and
M:P

20210811 Word To Excel Transpose Formulas etc.xlsx
ABCDEFGHIJKLMNOPQRSTUVWXYZAAABACADAEAFAGAHAI
1Contact NumberLength*Are you requesting to travel*Depart Sydney DATE OF TRAVEL Sydney Truck RunDepart Hazelbrook DATE OF TRAVELHazelbrook Truck RunDepart Sydney DATE OF TRAVEL Sydney Truck RunDepart Hazelbrook DATE OF TRAVELHazelbrook Truck RunTravel Category**NEW ** Day Counter**NEW MANUAL** TC Charge**NEW MANUAL** Truck Charge**NEW MANUAL** Total Amount $*Contact NumberLength*Are you requesting to travel*Depart Sydney DATE OF TRAVEL Sydney Truck RunDepart Hazelbrook DATE OF TRAVELHazelbrook Truck RunDepart Sydney DATE OF TRAVEL Sydney Truck RunDepart Hazelbrook DATE OF TRAVELHazelbrook Truck RunTravel Category**NEW ** Day Counter**NEW MANUAL** TC Charge**NEW MANUAL** Truck Charge**NEW MANUAL** Total Amount $***NEW MANUAL** Truck Charge MULTIPLIER
24426910106.5both ways (return)28/07/2021Blue Truck - Run 2, loading 10.30am28/07/2021Blue Truck - Run 2, loading 1.00pmOther Type114654664426910106.5both ways (return)28/07/2021Blue Truck - Run 2, loading 10.30am28/07/2021Blue Truck - Run 2, loading 1.00pmOther Type114654661
34303525946both ways (return)3/08/2021Blue Truck - Run 1, loading 6.30am3/08/2021Blue Truck - Run 2, loading 1.00pmOther Type112552564303525946both ways (return)3/08/2021Blue Truck - Run 1, loading 6.30am3/08/2021Blue Truck - Run 2, loading 1.00pmOther Type115105112
44582314305.3both ways (return)5/08/2021Blue Truck - Run 1, loading 6.30am6/08/2021Blue Truck - Run 2, loading 1.00pmRegular (GVM < 4.5 Tonne)2102552654582314305.3both ways (return)5/08/2021Blue Truck - Run 1, loading 6.30am6/08/2021Blue Truck - Run 2, loading 1.00pmRegular (GVM < 4.5 Tonne)2105105202
54458930145.6both ways (return)28/07/2021Blue Truck - Run 1, loading 6.30am30/07/2021Blue Truck - Run 1, loading 9.00amOther Type332552584458930145.6both ways (return)28/07/2021Blue Truck - Run 1, loading 6.30am30/07/2021Blue Truck - Run 1, loading 9.00amOther Type335105132
64737718509.3both ways (return)28/07/2021Blue Truck - Run 1, loading 6.30am30/07/2021Blue Truck - Run 1, loading 9.00amHeavy (GVM > 4.5 Tonne)3364655014737718509.3both ways (return)28/07/2021Blue Truck - Run 1, loading 6.30am30/07/2021Blue Truck - Run 1, loading 9.00amHeavy (GVM > 4.5 Tonne)3369309662
74614334349both ways (return)4/08/2021Blue Truck - Run 2, loading 10.30am6/08/2021Blue Truck - Run 1, loading 9.00amRegular (GVM < 4.5 Tonne)3154654804614334349both ways (return)4/08/2021Blue Truck - Run 2, loading 10.30am6/08/2021Blue Truck - Run 1, loading 9.00amRegular (GVM < 4.5 Tonne)3159309452
84893122709.9both ways (return)3/08/2021Blue Truck - Run 2, loading 10.30am6/08/2021Blue Truck - Run 2, loading 1.00pmHeavy (GVM > 4.5 Tonne)4487808284893122709.9both ways (return)3/08/2021Blue Truck - Run 2, loading 10.30am6/08/2021Blue Truck - Run 2, loading 1.00pmHeavy (GVM > 4.5 Tonne)448156016082
94288775797.5both ways (return)16/08/2021Blue Truck - Run 1, loading 6.30am19/08/2021Blue Truck - Run 2, loading 1.00pmRegular (GVM < 4.5 Tonne)4204654854288775797.5both ways (return)16/08/2021Blue Truck - Run 1, loading 6.30am19/08/2021Blue Truck - Run 2, loading 1.00pmRegular (GVM < 4.5 Tonne)4209309502
1045675641511.2to Hazelbrook26/07/2021Red Truck - Run 1, Loading 8:00am1#N/A78078045675641511.2to Hazelbrook26/07/2021Red Truck - Run 1, Loading 8:00am  00#N/A7807801
114444179999to Hazelbrook26/07/2021Red Truck - Run 1, Loading 8:00am1#N/A4654654444179999to Hazelbrook26/07/2021Red Truck - Run 1, Loading 8:00am  00#N/A4654651
124722968358to Hazelbrook23/07/2021Blue Truck - Run 1, loading 6.30am1#N/A4654654722968358to Hazelbrook23/07/2021Blue Truck - Run 1, loading 6.30am  00#N/A4654651
134599584199to Sydney28/07/2021Blue Truck - Run 1, loading 9.00am1#N/A4654654599584199to Sydney  28/07/2021Blue Truck - Run 1, loading 9.00am00#N/A4654651
144878372555.15to Sydney30/07/2021Blue Truck - Run 2, loading 1.00pm1#N/A2552554878372555.15to Sydney  30/07/2021Blue Truck - Run 2, loading 1.00pm00#N/A2552551
15
16
17Meterage FromMeterage ToPriceHELPER CELLS BELOW
181.53150CHARGES MATRIXDAILY RATE
193.016255Regular (GVM < 4.5 Tonne)5
206.019.5465Heavy (GVM > 4.5 Tonne)12
219.5112.5780Other Type1
2212.5118840
2318.123890
2423.11005
25Pallet
26
Data
Cell Formulas
RangeFormula
M2:M14M2=SUM(J2-H2)+1
N2:N14,AE2:AE14N2=VLOOKUP(L2,$I$18:$J$21,2,FALSE)*M2
O2:O14O2=IF(AND(B2<1.5),110,IF(AND(B2>1.49,B2<3.01),150,IF(AND(B2>3,B2<6.01),255,IF(AND(B2>6,B2<9.51),465,IF(AND(B2>9.5,B2<12.51),780,IF(AND(B2>12.5,B2<18.01),840,IF(AND(B2>23),1005,0)))))))
P2:P14,AG2:AG14P2=SUMIF(N2:O2,"<>#N/A")
R2:T14,AC2:AC14R2=A2
Y2:Z14Y2=IF($H2<>"",H2,IF($D2<>"",D2,""))
AA2:AB14AA2=IF($H2<>"",J2,IF($F2<>"",F2,""))
AD2:AD14AD2=IF(C2="both ways (return)",SUM(AA2-Y2)+1,0)
AF2:AF14AF2=VLOOKUP(S2,tbl_Meterage,3,TRUE)*AH2
AH2:AH14AH2=IF(AND(Y2<>"",AA2<>""), IF(Y2<>AA2, 2, IF(LEFT(Z2,FIND(",",Z2))<>LEFT(AB2,FIND(",",AB2)), 2, 1)), 1)
thank you, much appreciated, I'll suss it out and get back to you shortly.
 
Upvote 0
In case you haven't used Excel Tables before,
To convert the metreage data into a table:
  • Select any cell in the data range of the table
  • Either Insert > Table (3rd button from the left ) OR Ctrl + T
  • Give the Table the name tbl_Meterage
    Under Table Design > Table Name = White box on the far left
 
Upvote 0
In case you haven't used Excel Tables before,
To convert the metreage data into a table:
  • Select any cell in the data range of the table
  • Either Insert > Table (3rd button from the left ) OR Ctrl + T
  • Give the Table the name tbl_Meterage
    Under Table Design > Table Name = White box on the far left
Big big thanks Alex, sorry about the delayed reply. Great idea on the full hide, with input/output section, it all worked superb. Heaps of new stuff in there for me to learn/practice. Love the excel table, that really cleaned up that nested formula. thank you so much. This forum is so helpful. thanks again Alex.
 
Upvote 0

Forum statistics

Threads
1,215,459
Messages
6,124,945
Members
449,198
Latest member
MhammadishaqKhan

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