NamedRange.Parse(Object, Object) Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Parses a range of data and breaks it into multiple cells.
public object Parse (object ParseLine, object Destination);
abstract member Parse : obj * obj -> obj
Public Function Parse (Optional ParseLine As Object, Optional Destination As Object) As Object
Parameters
- ParseLine
- Object
A string that contains left and right brackets to indicate where the cells should be split. For example, "[xxx][xxx]" would insert the first three characters into the first column of the destination range, and it would insert the next three characters into the second column. If this argument is omitted, Microsoft Office Excel guesses where to split the columns based on the spacing of the top left cell in the range. If you want to use a different range to guess the parse line, use a Range object as the ParseLine
argument. That range must be one of the cells that is being parsed. The ParseLine
argument cannot be longer than 255 characters, including the brackets and spaces.
- Destination
- Object
A Range object that represents the upper-left corner of the destination range for the parsed data. If this argument is omitted, Excel parses in place.
Returns
Examples
The following code example uses the Parse method to parse each group of digits in a set of telephone numbers from a NamedRange control named NamedRange1
into a new range of cells starting at cell D1.
This example is for a document-level customization.
private void ParsePhoneNumbers()
{
this.Range["A1"].Value2 = "'5555550100'";
this.Range["A2"].Value2 = "'2065550101'";
this.Range["A3"].Value2 = "'4255550102'";
this.Range["A4"].Value2 = "'4155550103'";
this.Range["A5"].Value2 = "'5105550104'";
Microsoft.Office.Tools.Excel.NamedRange namedRange1 =
this.Controls.AddNamedRange(this.Range["A1", "A5"],
"namedRange1");
// Parse the phone numbers and insert them into
// the range starting at D1.
namedRange1.Parse("[XXX][XXX][XXXX]",
this.Range["D1"]);
}
Private Sub ParsePhoneNumbers()
Me.Range("A1").Value2 = "'5555550100'"
Me.Range("A2").Value2 = "'2065550101'"
Me.Range("A3").Value2 = "'4255550102'"
Me.Range("A4").Value2 = "'4155550103'"
Me.Range("A5").Value2 = "'5105550104'"
Dim namedRange1 As Microsoft.Office.Tools.Excel.NamedRange _
= Me.Controls.AddNamedRange(Me.Range("A1", "A5"), _
"namedRange1")
' Parse the phone numbers and insert them into
' the range starting at D1.
namedRange1.Parse("[XXX][XXX][XXXX]", Me.Range("D1"))
End Sub
Remarks
Distributes the contents of the NamedRange control to fill several adjacent columns. The NamedRange control can be no more than one column wide.