Hi
Sasikanth, below I've shared the code I used for my text to columns action. I built this a while ago and its been working fine on several developments so hopefully you find use of it. The set range sets the range if the endcell is not provided e.g. "A1" would then be set as "A1:A1"
Inputs - handle, wb name, ws name, startcell (this is the first row of the values you want to split A1), endcell (last row of values to be split A1000), split char (the character you want to delimit with such as | )
Outputs - Success, Message
----------------------------------------------------------------------
Dim wb, ws As Object
Dim excel, sheet, range As Object
Dim matrix = New Integer (3, 1) {{1, 1}, {2, 1}, {3, 1}, {4, 1}}
Try
wb = GetWorkbook(handle, Source_Workbook)
ws = GetWorksheet(handle, Source_Workbook, Source_Worksheet)
wb.Activate()
ws.Activate()
excel = ws.Application
sheet = excel.ActiveSheet
range = sheet.Range(CellRange)
range.Select()
excel.Selection.TextToColumns (Destination:=sheet.Range(Startcell), DataType:=1, _
TextQualifier:=-4142, ConsecutiveDelimiter:=False, Tab:=False, _
Semicolon:=False, Comma:=False, Space:=False, Other:=True, OtherChar _
:=Split_Char, FieldInfo:=matrix, _
TrailingMinusNumbers:=True)
Success = True
Catch e As Exception
Success = False
Message = e.Message
Finally
wb = Nothing
ws = Nothing
End Try
------------------------------
Michael ONeil
Technical Lead developer
NTTData
Europe/London
------------------------------