More dynamic vlookup formula that will allow to search a certain digits of number

feni1388

Board Regular
Joined
Feb 19, 2018
Messages
137
Office Version
  1. 2021
Platform
  1. Windows
Hello everyone....

I want to know whether it's possible to replace below formula with something more dynamic or not.

Excel Formula:
=VLOOKUP(VALUE(LEFT(A2,7)),F:G,2,FALSE)

My table data is as the following.

The problem is that the invoice number will grow to 8 digits and maximum 10 digits before it will be reset and go back to 1 digit number.
So is it possible to change the above formula to something that will vlookup only the numbers (no matter how many digits there're)?

Book1
ABCDEFG
1Invoice No.ResultInvoice No.Result
21000013 Total15100001315
31000014 Total1001000014100
41000015 Total30100001530
51000016 Total35100001635
61000017 Total40100001740
71000018 Total1501000018150
81000019 Total2001000019200
91000020 Total2251000020225
101000021 Total89100002189
111000022 Total90100002290
121000023 Total95100002395
131000024 Total1351000024135
141000025 Total2501000025250
151000026 Total2751000026275
161000027 Total55100002755
Sheet1
Cell Formulas
RangeFormula
B2:B16B2=VLOOKUP(VALUE(LEFT(A2,7)),F:G,2,FALSE)


Thank you in advance.
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
Based on ur formula, try this
Excel Formula:
=VLOOKUP(VALUE(SUBSTITUTE(A2," Total","")),F:G,2,FALSE)

if u can using Textbefore
Excel Formula:
=VLOOKUP(VALUE(TEXTBEFORE(A2," ")),F:G,2,FALSE)
 
Upvote 0
Solution
Another way :

Book1
ABCDEFG
1Invoice No.ResultInvoice No.Result
21000013 Total15100001315
31000014 Total1001000014100
41000015 Total30100001530
51000016 Total35100001635
61000017 Total40100001740
71000018 Total1501000018150
81000019 Total2001000019200
91000020 Total2251000020225
101000021 Total89100002189
111000022 Total90100002290
121000023 Total95100002395
131000024 Total1351000024135
141000025 Total2501000025250
151000026 Total2751000026275
161000027 Total55100002755
Sheet1
Cell Formulas
RangeFormula
B2:B16B2=VLOOKUP(VALUE(MID(A2,1,LEN(A2)-6)),F:G,2,FALSE)
 
Upvote 0
A slightly simpler version of post 3 suggestion would be:
Excel Formula:
=VLOOKUP(--LEFT(A2,LEN(A2)-6),F:G,2,0)

.. or you could use this in the top cell and not have to copy down the column
Excel Formula:
=VLOOKUP(--LEFT(A2:A16,LEN(A2:A16)-6),F:G,2,0)
 
Upvote 0
Another option:
Excel Formula:
=XLOOKUP(A2:A16,F2:F16&" Total",G2:G16)
 
Upvote 0
Cubist, I also tried yours, but it didn't work.
Works fine for me.
Book2
ABCDEFG
1Invoice No.ResultInvoice No.Result
21000013 Total15100001315
31000014 Total1001000014100
41000015 Total30100001530
51000016 Total35100001635
61000017 Total40100001740
71000018 Total1501000018150
81000019 Total2001000019200
91000020 Total2251000020225
101000021 Total89100002189
111000022 Total90100002290
121000023 Total95100002395
131000024 Total1351000024135
141000025 Total2501000025250
151000026 Total2751000026275
161000027 Total55100002755
Sheet1
Cell Formulas
RangeFormula
B2:B16B2=XLOOKUP(A2:A16,F2:F16&" Total",G2:G16)
Dynamic array formulas.
 
Upvote 0
@Cubist, I also tried yours, but it didn't work.
In what way did it not work? What result(s) did it return for that sample data?

If @Cubist's formula did not work, did the second formula I gave in post #4 work for you?
 
Upvote 0
In what way did it not work? What result(s) did it return for that sample data?

If @Cubist's formula did not work, did the second formula I gave in post #4 work for you?
Sorry, I only tried the first formula.
Now I tried the second one, and it returned SPILL .... just like Cubist's formula.
 
Upvote 0
Sorry, I only tried the first formula.
Now I tried the second one, and it returned SPILL .... just like Cubist's formula.
#SPILL error means, the formula produces a 2D ARRAY and is blocked by the cell that contains the value below it
 
Upvote 0

Forum statistics

Threads
1,225,611
Messages
6,185,993
Members
453,334
Latest member
Prakash Jha

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