Question : Inserting New row using excel VBA

Hello Experts,

 'Insert a New Row before the current row.(before the Result Row)



For rownum = 51 To 64000 Step 1
    If Worksheets("fvln").Cells(rownum, 4) = "" Then Exit For
   
                If Worksheets("fvln").Cells(rownum, 4) = "Result" Then
       
                ''Insert a New Row before the current row.(before the Result Row)
                   

       
                End If
   
   
    End If
           
    Next

Any help . Thanks

Answer : Inserting New row using excel VBA

Hi Mani,

To insert it above row 35, you would use
 Worksheets("fvln").Rows(35).Insert

But to me it sounds like you still want to go through each row one at a time and insert that way.  That WILL take a long time to run on bit sheets! Using my method above will take a split second.

However, if you still want to go through the cells one by one, using your method:

For rownum = 64000 To 51 Step -1
    If Worksheets("fvln").Cells(rownum, 4) = "" Then Exit For
                If Worksheets("fvln").Cells(rownum, 4) = "Result" Then
                 Worksheets("fvln").Rows(rownum).Insert
                ''Insert a New Row before the current row.(before the Result Row)
                End If
    End If
    Next

Make sure to start at the bottom and step -1, it will not work using an increasing number.
Random Solutions  
 
programming4us programming4us