Insert data in multiple rows

S

shantanu

Hello all

as per the code below, its reading 4 rows and i want all the four rows
to be inserted in new row of excel. Kindly help me to achieve the
same

if (srcRng1.Value2.ToString() == "Affected Products:")
{
for (int j = i; j <= i + 1; j++)
{
//Excel.Range range = (Excel.Range)
excel.Cells.get_Item(i, j);
//range.Insert
(Excel.XlInsertShiftDirection.xlShiftDown, System.Type.Missing);



TempAP = _shtSrc.get_Range("B" + j.ToString
(), Type.Missing);
destRng1.Insert
(Excel.XlInsertShiftDirection.xlShiftDown, Type.Missing);
destRng1.Value2 = TempAP.Value2;


}
}


Thanks
Shantanu
 
R

ryguy7272

I don't know what your code is supposed to do, but based on your description,
i think this is what you want:

Do three things before you run the code: backup, backup, and backup!!
Sometimes the consequences are unintended and it's a PITA to undo things
that have been done, and done wrong!!

Sub MergeCols()

Dim FBlank As Boolean
Dim FRow As Integer
FRow = 1
FBlank = IsEmpty(Cells(FRow, 1).Value)
Do While FBlank = False
Rows(FRow + 1 & ":" & FRow + 3).Insert Shift:=xlDown
Cells(FRow, 2).Cut Destination:=Range("A" & FRow + 1)
Cells(FRow, 3).Cut Destination:=Range("A" & FRow + 2)
Cells(FRow, 4).Cut Destination:=Range("A" & FRow + 3)
FRow = FRow + 4
FBlank = IsEmpty(Cells(FRow, 1).Value)
Loop

End Sub

Regards,
Ryan---
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top