Breaking my head with this formula

RafaelGS

New Member
Joined
Jun 11, 2018
Messages
2
jAYc2o
NumberDescriptionMeasurement (mm)
5897652Erhöhungsrahmen, MEF33, 320x320x75
2145456text....
Größe: BxHxT = 900x1250+(800(Sockel) = ignore)x340 mm
Text...
2548578Only text (ignore)
3579513Text…
H:1710mm, B:838,5mm, T:277mm

<tbody>
</tbody>

Hello everyone, I'm struggling with this formula for a while now, I need to get just the measurements of the cells under "description", let's say B2, B3... and put it in Measurement: C2, C3,...
The problem is that there are those 4 different kinds of problems, they are not in a pattern. I've tried everything, =left, =mid, with find, with it. Someone sees a way out of it? Would really appreciate.

Thank you beforehand.
 

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.
And what exactly do you want to appear in C1, C2 and C4? Is it 75, 340 and 277? Or something else?
 
Upvote 0
I'm not smart enough to do it in a formula - I'd do it with a User Defined Function (VBA). That will probably be easier to understand if you need to modify it later.

Try this:-

Code:
Option Explicit

Public Function get_mms(ByVal arg As String) As String

  Application.Volatile
 
  Dim iPtr As Integer
  Dim iPtr2 As Integer
  
  arg = Replace(arg, "mm, ", "mm ")
  
  iPtr = InStrRev(arg, ", ")
  If iPtr > 0 Then arg = Mid(arg, iPtr + 2)
  
  For iPtr = 1 To Len(arg)
    Select Case Mid(arg, iPtr, 1)
      Case "0" To "9", "(", ")", ","
        ' do nowt
      Case Else
        arg = Left(arg, iPtr - 1) & " " & Mid(arg, iPtr + 1)
    End Select
  Next iPtr
  
  iPtr = InStr(arg, "(")
  Do While iPtr > 0
    iPtr2 = InStrRev(arg, ")")
    arg = Left(arg, iPtr - 1) & Mid(arg, iPtr2 + 1)
    iPtr = InStr(arg, "(")
  Loop
  
  iPtr = InStr(arg, "  ")
  Do While iPtr > 0
    arg = Left(arg, iPtr - 1) & Mid(arg, iPtr + 1)
    iPtr = InStr(arg, "  ")
  Loop
  
  get_mms = Replace(Trim(arg), " ", "x")
  
End Function
 
Upvote 0
In a copy of your workbook, press Alt-F11 to open Microsoft Visual Basic, press Ctrl-R to view the Project Explorer, then go Insert > Module. A new 'standard' module will appear under Modules, probably called Module1. Double-click the name of this new module to open it, then paste my code in.

Then in your sheet, use the new function like so: =get_mms(b2)
 
Upvote 0

Forum statistics

Threads
1,214,923
Messages
6,122,289
Members
449,077
Latest member
Rkmenon

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