Defining Ranges

Excel provides the Parse method that you can use to separate data values in one column into multiple columns. The method works well when you have string data that is all the same length, such as phone numbers. With the Parse method, you specify how the strings in each cell should break and Excel applies that format to each cell.

There are two optional parameters for the Parse method. The first parameter, ParseLine, is a string containing left and right brackets indicating where the cells should split. For example, [xxxx] [xxxx] breaks each string so that the first four characters are placed in the first column and the second four characters are placed in the second column. Any characters outside those characters are ignored and not moved to a new column. If the string is "Alphabetical", with this ParseLine parameter, Excel places the first four characters Alph in the first column and the second four characters, abet in the second column. The remaining characters in the string, ical, are ignored because they are not specified as part of the ParseLine value.

The second parameter, Destination, specifies the range where the parsed data is placed. If you specify a range of more than one cell, Excel uses the upper left corner of the range as the first cell.

Texttocolumns

RangeVar.TextToColumns.

Q Type

DataType:=xlDelimited. _Q Type Comma:=True

0 Switch to Excel and run the macro.

■ Excel breaks the contents of the specified column into two separate columns.

RangeVar.TextToColumns.

Type Destination :=Range("B1"), replacing Range("B1") with the location to place the cells.

Q Type

DataType:=xlDelimited. _Q Type Comma:=True

0 Switch to Excel and run the macro.

■ Excel breaks the contents of the specified column into two separate columns.

0 0

Post a comment