Saturday, April 3, 2010

How to merger cells in Excel using VBScript

How to merger cells in Excel using VBScript

[Difference is in the last line of each script]

Set objExcel1 = CreateObject("Excel.Application")
objExcel1.Visible = True
objExcel1.Workbooks.Add
objExcel1.ActiveWorkbook.ActiveSheet.Cells(1, 1).Value = "Title of Of the three columns"
objExcel1.ActiveWorkbook.ActiveSheet.Range("A1:C1").Merge

OR

Set objExcel1 = CreateObject("Excel.Application")
objExcel1.Visible = True
objExcel1.Workbooks.Add
objExcel1.ActiveWorkbook.ActiveSheet.Cells(1, 1).Value = "Title of Of the three columns"
objExcel1.ActiveWorkbook.ActiveSheet.Range(objExcel1.ActiveWorkbook.ActiveSheet.Cells(1, 1), objExcel1.ActiveWorkbook.ActiveSheet.Cells(1,3)).Merge

[Via]