Merge cells in Excel
4 answers
A sheet cell property refers to a single cell. So you are trying to concatenate only the cell on A10. As its already one cell, it does nothing. I'm not sure if you can only do this with the Cells property as it will always only be one cell. Why are you avoiding Range?
This uses a range but will still use the cells property to set range constraints
excelSheet.Range(excelSheet.Cells(1, 1),excelSheet.Cells(1, 10)).Merge
Also, I think the command is Merge and not Merge (), at least when I run it.
Sorry if that doesn't help, give us more details and I'll look heavier if it doesn't work for you.
+18
a source to share
Try it. It can only be used for a range. I don't know how to merge cells.
Dim xlsApp As New Excel.Application
xlsApp .Visible = True
Dim xlsWorkbook As Excel.Workbook = xlsApp.Workbooks.Open("..\TestWorkbook.xls")
Dim xlsWorkSheet As Excel.Worksheet = DirectCast(xlsWorkbook.Worksheets("Sheet1"), Excel.Worksheet)
xlsWorkSheet.Range("A1:D1").MergeCells = True
Don't forget to import the required libraries.
0
a source to share