split cell accross help

wrighty998

New Member
Joined
Jan 31, 2018
Messages
35
please help with a formula to split my cell

input cell

DSEN 52, DTOR 3, DAMR 79, SSEN 0, STOR 2, SAMR 5, SPROD YES

<tbody>
</tbody>

<tbody>
</tbody>

<tbody></tbody>

output cells

52379025yes

<tbody>
</tbody>
 

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.
You can use a custom function. I have your string in cell A1. Then you can put =SplitIt($A$1,COLUMN(A1)) in cell B1 and copy it across to the right. Here is the code for the function.

Code:
Function SplitIt(r As Range, idx As Integer) As String
Dim SP() As String
Dim S() As String


SP = Split(r.Value, ", ")
S = Split(SP(idx - 1), " ")


SplitIt = S(1)
End Function
 
Upvote 0
You can use a custom function. I have your string in cell A1. Then you can put =SplitIt($A$1,COLUMN(A1)) in cell B1 and copy it across to the right. Here is the code for the function.

Code:
Function SplitIt(r As Range, idx As Integer) As String
Dim SP() As String
Dim S() As String


SP = Split(r.Value, ", ")
S = Split(SP(idx - 1), " ")


SplitIt = S(1)
End Function

wont work pal,

data is in M2 and im putting formula on a diff tab
 
Upvote 0
Seems to work with my testing. Try this, changing Sheet2!$M$2, to whatever your sheet name with the data in it is called.

Code:
=SplitIt(Sheet2!$M$2,COLUMN(A1))
 
Upvote 0
The custom function has 2 arguments. The first on is the range where your data is. The second one is an index. The code is splitting your data into an array. The array splits up your data using the commas and spaces. DSEN 52, DTOR 3, DAMR 79, SSEN 0, STOR 2, SAMR 5, SPROD YES. So the first item in the array is DSEN 52, the second is DTOR 3, and so on. So column(A1) is just a way to get an number to increment 1,2,3,.... to reference the various elements in the array.
 
Upvote 0
still says #NAME ?
What is the name of the Module where you put this User Defined Function in?
Are you sure you put it in a Module in the same workbook as your data (if you have more than one Excel file open, it is possible you could have put it in the wrong workbook)?

If you have put it in the correct place, then if you start typing =SplitIt in any cell, the formula assistant should pop-up and it should show you all functions that start with that name.
If you do not see that pop-up, you have put your code in the wrong place.
 
Upvote 0
What is the name of the Module where you put this User Defined Function in?
Are you sure you put it in a Module in the same workbook as your data (if you have more than one Excel file open, it is possible you could have put it in the wrong workbook)?

If you have put it in the correct place, then if you start typing =SplitIt in any cell, the formula assistant should pop-up and it should show you all functions that start with that name.
If you do not see that pop-up, you have put your code in the wrong place.

no it does not work opened a new workbook and tried it in there also saved it as a micro enabeled workbook, wont show when typing it in :(
 
Upvote 0
Going back to an earlier question I asked:
What is the name of the Module where you put this User Defined Function in?
 
Upvote 0

Forum statistics

Threads
1,215,059
Messages
6,122,916
Members
449,093
Latest member
dbomb1414

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