Looking to Adapt This or New One to Parse Cell by Character

Alex20850

Board Regular
Joined
Mar 9, 2010
Messages
146
Office Version
  1. 365
Platform
  1. Windows
My data looks like this:
[TABLE="width: 236"]
<tbody>[TR]
[TD]c2=\Data Tab\Get & Transform[/TD]
[/TR]
[TR]
[TD]c3=\View Tab\Show/Hide\Ruler

I am looking for a function - for this example named Parse where Parse(c2,"",1) equals Data Tab
Parse(c3,"",2) equals Show/Hide[/TD]
[/TR]
[TR]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
Public Function separate(field As String, separator As String)
Dim fieldlength As Integer
fieldlength = Len(field)
separate = ""
Dim i As Integer
For i = 1 To fieldlength
separate = separate + Mid(field, i, 1)
separate = separate + separator
Next
separate = Mid(separate, 1, (fieldlength * 2) - 1)
End Function
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
Does this function do what you want? The first argument is either a cell reference containing text or expression evaluating to a text string, the second argument is the text to be used as the delimiter separating the fields and the third argument is the field number to return.
Code:
[table="width: 500"]
[tr]
	[td]Function Field(Text As String, Delimiter As String, FieldNumber As Long) As String
  Field = Split(Text, Delimiter)(FieldNumber)
End Function[/td]
[/tr]
[/table]
Note: The FieldNumber argument starts at 0 which is the text before the first delimiter.
 
Upvote 0
Wonderful!! Very short, too the point, and powerful!! Thank you!
 
Upvote 0

Forum statistics

Threads
1,224,820
Messages
6,181,162
Members
453,021
Latest member
Justyna P

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