[2005] Merging Cells in Excel
I want to insert a value in the cell of excel, I did it, Now i have to merge the next cell too..
For example, i have inserted "Sample" in the the cell (2,B+C)
2 -> Row.
B+C -> Columns to be merged.
In this way i inserted the value,
Code:
WorkSheets.Cells(2,B).value="Sample"
Next how to merge it,????
Re: [2005] Merging Cells in Excel
Code:
Worksheets.Range("A1","B1").Merge()
this works great for merging the cells,But three cells(A1,B1,C1) merging and
when we do merge manually,the value inside the cell alligned "Center" automatically, When i try through coding its not happening,the value is in left left, i.e the value in the "A1" alone
What i want to do for this??
Re: [2005] Merging Cells in Excel
Thread Moved
Thats because it does two tasks at once, hence "Merge & Center".
Code:
Public Sub MegerCenter()
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Selection.Merge
End Sub
Re: [2005] Merging Cells in Excel
Thanks Rob, i solved it on that day itself from ur signature
Re: [2005] Merging Cells in Excel
try this
Code:
objRango = objHojaExcel.Range("A7:D7")
objRango.Merge()
objRango.HorizontalAlignment = Excel.Constants.xlCenter
objRango.WrapText = True
objRango.ShrinkToFit = True
Re: [2005] Merging Cells in Excel
vb Code:
Dim range1 As Excel.Range
range= xlWorkSheet.Range("A1", "A2")
range.Merge()
it doenst merge the cells.. how can i fix this
Re: [2005] Merging Cells in Excel
I don't remember the exact syntax but try any one of the below.
1)
Dim range1 As Excel.Range
Range = xlWorksheet.Range("A1:A2")
Range.Merge()
2) xlWorksheet.Range("A1", "A2").Merge
3)
Dim range1 As Excel.Range
Range = xlWorksheet.Range("A1", "A2")
Range.Merge (True)
Sid