Hi All,
I am using this code to insert one row and trying to merge cells (G21:I31).
It is merging G54:I54 .. Any ideas ?Code:Private Sub InsertRow(ByVal sheet As Excel.Worksheet, ByVal rowcount As Integer) Dim range As Excel.Range Dim row As Excel.Range Dim remark As Excel.Range Dim newRow As Excel.Range Dim _newrow As Integer = rowcount - _TRIPREPORTROWS If rowcount > _TRIPREPORTROWS Then 'Select the Last DataRow range = sheet.Range(_RowRange & _RowIndex) row = range.EntireRow For index As Integer = 1 To _newrow 'Insert N new Rows row.Insert(xlShiftDown) 'Insert one Row newRow = sheet.Range(_RowRange & _RowIndex) 'Get the New Row remark = newRow.EntireRow.Range("G32:I32") 'Get the new Row Range remark.Cells.Merge() 'Merge Next End If End Sub




Reply With Quote