Separating the string

Ranju78

New Member
Joined
Apr 27, 2018
Messages
15
I have a column where customer can input the Manufacturer and model number like
Goodman FGTRD-25418
Phillip HGYTFD25148jnh
HYGFN84K
YTR5245F Samsung
Sonic

<tbody>
</tbody>

Now I have another two column where I have to put Manufacturer and model number like below
How do i do this ..
Manufacturer model number
GoodmanFGTRD-25418
PhillipHGYTFD25148jnh
HYGFN84K
Samsung YTR5245F
Sonic

<tbody>
</tbody>


Please help
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
Re: Need help with separating the string

Do you have a unique list of Manufacturers that could be referenced? If not is it easy to create one?
 
Upvote 0
Re: Need help with separating the string

Assuming your Model Numbers always start with two upper case letters as you examples show, then here is a pair of UDFs (User Defined Functions) that will return the values that you want (the function names tell you which column to place each one in)...
Code:
[table="width: 500"]
[tr]
	[td]Function Manufacturer(S As String) As String
  Dim X As Long, UpperLower As Long, TwoUppers As Long
  For X = 1 To Len(S)
    If UpperLower = 0 And Mid(S, X, 2) Like "[A-Z][a-z]" Then UpperLower = X
    If TwoUppers = 0 And Mid(S, X, 2) Like "[A-Z][A-Z]" Then TwoUppers = X
  Next
  If TwoUppers > UpperLower Then
    Manufacturer = Trim(Left(S, TwoUppers - 1))
  Else
    Manufacturer = Trim(Mid(S, UpperLower))
  End If
End Function

Function ModelNumber(S As String) As String
  Dim X As Long, UpperLower As Long, TwoUppers As Long
  For X = 1 To Len(S)
    If UpperLower = 0 And Mid(S, X, 2) Like "[A-Z][a-z]" Then UpperLower = X
    If TwoUppers = 0 And Mid(S, X, 2) Like "[A-Z][A-Z]" Then TwoUppers = X
  Next
  If TwoUppers > UpperLower Then
    ModelNumber = Trim(Mid(S, TwoUppers))
  Else
    ModelNumber = Trim(Left(S, UpperLower - 1))
  End If
End Function[/td]
[/tr]
[/table]

HOW TO INSTALL UDFs
------------------------------------
If you are new to UDFs, they are easy to install and use. To install it, simply press ALT+F11 to go into the VB editor and, once there, click Insert/Module on its menu bar, then copy/paste the above code into the code window that just opened up. That's it.... you are done. You can now use Manufacturer and ModelNumber just like it was a built-in Excel function. For example,

=Manufacturer(A1)

=ModelNumber(A1)

If you are using XL2007 or above, make sure you save your file as an "Excel Macro-Enabled Workbook (*.xlsm) and answer the "do you want to enable macros" question as "yes" or "OK" (depending on the button label for your version of Excel) the next time you open your workbook.
 
Upvote 0
Re: Need help with separating the string

Hi Rick,

Haven't tested your UDF, but was just curious, would it hold for Manufacturers/Companies like: AT&T, IBM, HP, AOL (is AOL still around?), just some samples....
 
Upvote 0
Re: Need help with separating the string

Haven't tested your UDF, but was just curious, would it hold for Manufacturers/Companies like: AT&T, IBM, HP, AOL (is AOL still around?), just some samples....
No, my UDF would not work for those... nor would anyone else's UDF either as there is nothing solid to go on with them (I'm thinking of the 3M company when I say that when I say that).
 
Upvote 0

Forum statistics

Threads
1,214,641
Messages
6,120,691
Members
448,978
Latest member
rrauni

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