Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Insert Multiple Rows Trouble
Hi,
I am new to VBA and just finished my first program which is working well but I have a question about part of it. At one point in the process I have the macro search out a cell with a certain value and then I want it to insert 21 rows after that cell. For some reason in order to get 21 rows I have to run the loop 42 times. Below is how I did it. It inserts 21 rows. Does anyone know why I have to loop twice as many times as I think I should. Also I am sure there is a more efficient way to do this and would welcome learning a quicker way to acheive the same goal. Thanks for your help. ' Insert 21 rows after NOI i = 0 For Each Cell In ActiveSheet.UsedRange If Cell.Value = "Net Operating Income" Then Cell.Select For i = 1 To 42 Rows(ActiveCell(2).Row).Insert i = i + 1 Next i End If Next Cell |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
how do insert multiple rows in between multiple lines | Excel Discussion (Misc queries) | |||
Insert Multiple Rows | Excel Discussion (Misc queries) | |||
Trouble using macros to insert rows | Excel Discussion (Misc queries) | |||
Insert Multiple rows | Setting up and Configuration of Excel | |||
Insert multiple rows | Excel Programming |