Range.TextToColumns(Object, XlTextParsingType, XlTextQualifier, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object) Range.TextToColumns(Object, XlTextParsingType, XlTextQualifier, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object) Method

Definition

Parses a column of cells that contain text into several columns.

public object TextToColumns (object Destination, Microsoft.Office.Interop.Excel.XlTextParsingType DataType = Microsoft.Office.Interop.Excel.XlTextParsingType.xlDelimited, Microsoft.Office.Interop.Excel.XlTextQualifier TextQualifier = Microsoft.Office.Interop.Excel.XlTextQualifier.xlTextQualifierDoubleQuote, object ConsecutiveDelimiter, object Tab, object Semicolon, object Comma, object Space, object Other, object OtherChar, object FieldInfo, object DecimalSeparator, object ThousandsSeparator, object TrailingMinusNumbers);
Public Function TextToColumns (Optional Destination As Object, Optional DataType As XlTextParsingType = Microsoft.Office.Interop.Excel.XlTextParsingType.xlDelimited, Optional TextQualifier As XlTextQualifier = Microsoft.Office.Interop.Excel.XlTextQualifier.xlTextQualifierDoubleQuote, Optional ConsecutiveDelimiter As Object, Optional Tab As Object, Optional Semicolon As Object, Optional Comma As Object, Optional Space As Object, Optional Other As Object, Optional OtherChar As Object, Optional FieldInfo As Object, Optional DecimalSeparator As Object, Optional ThousandsSeparator As Object, Optional TrailingMinusNumbers As Object) As Object
Parameters
Destination
Object Object

Optional Object. A Range object that specifies where Microsoft Excel will place the results. If the range is larger than a single cell, the top left cell is used.

DataType
XlTextParsingType XlTextParsingType

Optional XlTextParsingType. The format of the text to be split into columns. Can be one of the following XlTextParsingType constants:xlDelimited defaultxlFixedWidth

TextQualifier
XlTextQualifier XlTextQualifier

Optional XlTextQualifier. Can be one of the following XlTextQualifier constants:xlTextQualifierDoubleQuotedefaultxlTextQualifierNonexlTextQualifierSingleQuote

ConsecutiveDelimiter
Object Object

Optional Object. True to have Microsoft Excel consider consecutive delimiters as one delimiter. The default value is False.

Tab
Object Object

Optional Object. True to have DataType be xlDelimited and to have the tab character be a delimiter. The default value is False.

Semicolon
Object Object

Optional Object. True to have DataType be xlDelimited and to have the semicolon be a delimiter. The default value is False.

Comma
Object Object

Optional Object. True to have DataType be xlDelimited and to have the comma be a delimiter. The default value is False.

Space
Object Object

Optional Object. True to have DataType be xlDelimited and to have the space character be a delimiter. The default value is False.

Other
Object Object

Optional Object. True to have DataType be xlDelimited and to have the character specified by the OtherChar argument be a delimiter. The default value is False.

OtherChar
Object Object

Optional Object (required if Other is True). The delimiter character when Other is True. If more than one character is specified, only the first character of the string is used; the remaining characters are ignored.

FieldInfo
Object Object

Optional Object. An array containing parse information for the individual columns of data. The interpretation depends on the value of DataType. When the data is delimited, this argument is an array of two-element arrays, with each two-element array specifying the conversion options for a particular column. The first element is the column number (1-based), and the second element is one of the XlColumnDataType constants specifying how the column is parsed. Can be one of the following XlColumnDataType constants:xlGeneralFormat. Genera. xlTextFormat. Text.xlMDYFormat. MDY Date.xlDMYFormat. DMY Date.xlYMDFormat. YMD Date.xlMYDFormat. MYD Date.xlDYMFormat. DYM Date.xlYDMFormat. YDM Date.xlEMDFormat. EMD Date.xlSkipColumn. Skip Column.You can use xlEMDFormat only if Taiwanese language support is installed and selected. The xlEMDFormat constant specifies that Taiwanese era dates are being used.The column specifiers can be in any order. If a given column specifier is not present for a particular column in the input data, the column is parsed with the General setting.If the source data has fixed-width columns, the first element of each two-element array specifies the starting character position in the column (as an integer; 0 (zero) is the first character). The second element of the two-element array specifies the parse option for the column as a number from 1 through 9, as listed above.

DecimalSeparator
Object Object

Optional String. The decimal separator that Microsoft Excel uses when recognizing numbers. The default setting is the system setting.

ThousandsSeparator
Object Object

Optional String. The thousands separator that Excel uses when recognizing numbers. The default setting is the system setting.

TrailingMinusNumbers
Object Object

Optional Object. Numbers that begin with a minus character.

Returns

Remarks

The following table shows the results of importing text into Excel for various import settings. Numeric results are displayed in the rightmost column.

PeriodCommaCommaPeriod123.123,45123,123.45 (numeric)
PeriodCommaCommaComma123.123,45123.123,45 (text)
CommaPeriodCommaPeriod123,123.45123,123.45 (numeric)
PeriodCommaPeriodComma123 123.45123 123.45 (text)
PeriodCommaPeriodSpace123 123.45123,123.45 (numeric)

Applies to