View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Charlie Charlie is offline
external usenet poster
 
Posts: 703
Default Function to return Character Position of Xth character within a st

Sounds like all you want to do is parse each string on commas. Use the Split
function. It returns a string array (zero-based) parsed using the character
you select.

Dim MyData() As String
Dim strCSV As String
Dim i As Long
Dim OneItem As String

MyData = Split(strCSV, ",")

For i = 0 To UBound(MyData)
OneItem = MyData(i)
....do whatever...
Next i



"Andibevan" wrote:

Hi All,

I have a CSV data extract that I am trying to automatically seperate using a
formula -each string contains about 10 pieces of data each seperated by a
comma

I am trying to find / build a function that can return the character
position within the string of the Xth comma - I also need to be able to
specify whether it looks for the xth comma from the front or the back of the
string.

I am currently achieving this by using multiple Mid and SEARCH functions but
the formulas end up enormous and are hard to maintain.

Any help would be really appreciated

Ta

Andi