Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I am trying to write some code to insert a row above
whenever a "1" is found in Column A. For instance, if a "1" is found in col A, row 10, I want to insert a row above so that all cells are moved down. My problem is figuring out how to tell it to select a particular row when I don't know what the row number will be. I've written the following code: Dim rng As Range Dim cell As Range Set rng = Range(Cells(2, 1), Cells(Rows.Count, 1).End (xlUp)) For Each cell In rng If cell.Value = 1 Then Rows(cell).Select Selection.Insert Shift:=xlDown End If Next the problem is that because the first cell is A2, it stops and selects that row and inserts the line at that point, regardless of whether the cell contains a "1", and doesn't go on to the next cell in the range. |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
inserting rows inbetween rows of data ? | Excel Discussion (Misc queries) | |||
Copying & Inserting Rows w/o Affecting other Rows Etc. | Excel Worksheet Functions | |||
inserting rows | Excel Discussion (Misc queries) | |||
Inserting Blank rows after every row upto 2500 rows | Excel Worksheet Functions | |||
inserting rows | Excel Discussion (Misc queries) |