tags:

views:

116

answers:

1

How to merge cells using Cell and not Range in vb.net

I'll try this code but it doesn't work

excelSheet.Cells(1, 10).Merge()

Can anyone help me..

A: 

The cells property of a worksheet refers to a single cell. So you are trying to merge just the cell at A10. As its already one cell, this doesn't do anything. I'm not sure you can do it with just the Cells property, as it will always be one cell only. Why are you avoiding Range?

This uses range, but would still use the cells property to target the range constraints

excelSheet.Range(excelSheet.Cells(1, 1),excelSheet.Cells(1, 10)).Merge

Also, I think the command is Merge, not Merge(), at least when I run it.

Sorry if that isn't helpful, give us some more details and I'll look harder if that doesn't work for you.

goggin13
Ohh!! Thanks goggin.. It works!! :)
Mark