Extracting numbers from a text and multiplying them numbers eachother

cadandcode

Board Regular
Joined
Jan 21, 2023
Messages
125
Office Version
  1. 2019
Platform
  1. Windows
  2. Mobile
Hello, I checked most of the topics but couldnt find the exact formula.

AB
14 M 10 AD40
220 M 7 AD140

I would like to get B2 results just like that from A1 and A2 columns. Extract 4 and 10 from A1 and multiply them eachother in B1 (B1 is just an example) like I tried to describe above.
I found a vba code to extract 4 and 10 from that text cell into B1 like "410" but I couldnt find a way to multiply them as "=4*10" in B1 instead of putting them together like "410".
 
You have the code in the wrong place. It should be in a standard module, not the ThisWorkbook module

1674450751713.png


Don't use Ctrl+Shift+Enter
 
Upvote 0

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)
cuz i thought u wanted the result of each cell in the cell next to it, not all the ranges in 1 cell just like your example. it'll work on 1 cell at a time not the whole range.
 
Upvote 0
cuz i thought u wanted the result of each cell in the cell next to it, not all the ranges in 1 cell just like your example. it'll work on 1 cell at a time not the whole range.
I need one cell to include the cells in the range that I set, sir.
@Peter_SSs you are welcome sir
 
Upvote 0
I need one cell to include the cells in the range that I set, sir.
That is not clear to me. Do you mean that you need the function to work even if there is only one cell in the range?

If so, is there an option for you to use the function like this, referencing an empty cell below?

cadandcode.xlsm
AB
1
24 M 10 AD40
3
Sheet1
Cell Formulas
RangeFormula
B2B2=SUMPROD(A2:A3)
 
Upvote 0
@Peter_SSs I would like to explain.
There will be a cell (random cell I will decide) which contains results. Results of that formula calculates as taking numbers only and multiplying them. That 1 cell I tell in the beginning will have all results.
For example; B1 will be result cell. A1 have 4M 10, A2 has 5 KG 4M 10 AD and so. B1 (result cell) will be B1=(4*10)+(5*4*10)
And I will be able to change that B1 (result cell) to another cell. Code should let me change that result cell (B1) to another cell I decided.
Therefore, code should let me decide which rows/columns will be calculated in B1(result cell).
Like there is A1= 4M 10, A2= 10 M 20 KG, A3= 2M 3 AD and I wont add A3 in calculation and want to add another cell in calculation like AK= 40 M 10 AD 20 KG and B1(result cell)= (4*10)+(10*20)+(40*10*20)
Code should let me choose cells. Not calculate all cells in sheet. And there should be 1 cell that calculates also let me choose its place to put.
 
Upvote 0
I have no idea what that was all about. Can you
- post a small set of sample data with XL2BB where the existing function does not produce the expected result
- tell us what the expected result is and why
 
Upvote 0
I have no idea what that was all about. Can you
- post a small set of sample data with XL2BB where the existing function does not produce the expected result
- tell us what the expected result is and why
Adding XL2BB gave security error
 
Upvote 0

Forum statistics

Threads
1,223,886
Messages
6,175,193
Members
452,616
Latest member
intern444

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