Friday, April 2, 2010

VBScript - Using the Text to Columns Feature in Microsoft Excel

VBScript - Using the Text to Columns Feature in Microsoft Excel

Set objExcel = CreateObject("Excel.Application")
objExcel.Visible = True
Set objWorkbook = objExcel.Workbooks.Add()
Set objWorksheet = objWorkbook.Worksheets(1)

objExcel.Cells(1, 1).Value = "Olympia, WA"
objExcel.Cells(2, 1).Value = "Salem, OR"
objExcel.Cells(3, 1).Value = "Boise, ID"
objExcel.Cells(4, 1).Value = "Sacramento, CA"

Set objRange = objExcel.Range("A1").EntireColumn
Set objRange2 = objExcel.Range("B1")

objRange.TextToColumns objRange2,,,,,,TRUE

[Via]