csutaria

New Member
Joined
Apr 3, 2009
Messages
20
Does anyone know the syntax to convert text to table using 2 delimiters (~ to switch to the next column and "&" to switch to the next row)?

I'm planning to use it as part of a macro for MS Project 2003 but I figure it would be pretty much the same in excel.

Any help would be greatly appreciated.
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
I'm not following exactly what you are asking here?

Do you have a lot of data in a cell separated by ~ and & and then depending on those to move the data to the next column or row?
 
Upvote 0
Hi,

Try these macros and choose the applicable one:

Rich (BB code):
<font face=Courier New>
' Using of Excel .TextToColumns method
Sub TxtToExcelColumns(Txt As String, DestUpperLeftCell As Range)
  Dim arr
  arr = Split(Txt, "&")
  With DestUpperLeftCell.Cells(1, 1).Resize(UBound(arr) + 1)
    .Value = arr
    .TextToColumns Destination:=.Cells(1, 1), _
                   ConsecutiveDelimiter:=False, _
                   DataType:=xlDelimited, _
                   Other:=True, OtherChar:="~"
  End With
End Sub

Sub Test_TxtToExcelColumns()
  Dim Txt As String
  Txt = "Txt1.1~Txt1.2~Txt1.3~1~2~3&Txt2.1~Txt2.2~Txt2.3~4~5~6"
  ' If Txt is in [A1] cell then uncomment the line below
  'Txt = Range("A1").Value
  TxtToColumns Txt, Range("A2")
End Sub
</FONT>

Rich (BB code):
<font face=Courier New>
' Using of Replace function
Function TxtToTabColumns(Txt As String)
  TxtToTabColumns = Replace(Replace(Txt, "&", vbLf), "~", vbTab)
End Function

Sub Test_TxtToTabColumns()
  Dim Txt As String
  Txt = "Txt1.1~Txt1.2~Txt1.3~1~2~3&Txt2.1~Txt2.2~Txt2.3~4~5~6"
  MsgBox TxtToTabColumns(Txt)
End Sub</FONT>

Regards,
Vladimir
 
Upvote 0

Forum statistics

Threads
1,214,649
Messages
6,120,733
Members
448,987
Latest member
marion_davis

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