Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Subject: Inserting rows based on another cells value
From: "MikeT" Sent: 4/8/2004 12:58:57 PM Thanks Frank, In the rows that are inserted, can I copy the data from certain cells(not the whole row, but constant certain cells) from the row above that caused the insert. Thanks for your help MikeT -----Original Message----- Hi Mike try the following: Sub insert_rows() Dim lastrow As Long Dim row_index As Long lastrow = ActiveSheet.Cells(Rows.count, "A").End(xlUp).row For row_index = lastrow - 1 To 1 Step -1 with Cells(row_index, "A") If .Value =2 or .value = 3 then Cells(row_index + 1, "A").resize(.value- 1,1).EntireRow.Insert (xlShiftDown) End If end with Next End Sub -- Regards Frank Kabel Frankfurt, Germany MikeT wrote: I have a column of cells that could have the value of either 1, 2 or 3. I want 1 row added below the cell if the value is 2, 2 rows added below the cell if the value is 3 and no cells added if the value is 1. Anyone know if this is possible and if it is how is it done. . .. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
inserting rows keeping the merged cells | Excel Discussion (Misc queries) | |||
need help please inserting multiple rows based on cell value then copying to data sheet | Excel Worksheet Functions | |||
inserting a named range into new cells based on a named cell | Excel Discussion (Misc queries) | |||
Inserting rows based on count | Excel Programming | |||
Inserting rows based on another cells value | Excel Programming |