Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi,
Somewhere in column A, a cell contains the text "sales". Within a macro I want to insert 3 rows above the row that has "sales" in it. Is this possible? TIA Matt |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi
try the following macro. 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 If lcase(Cells(row_index+1, "A").Value) ="sales" Then Cells(row_index + 1, "A").resize(3,1).EntireRow.Insert _ (xlShiftDown) End If Next End Sub -- Regards Frank Kabel Frankfurt, Germany "Matt B" schrieb im Newsbeitrag m... Hi, Somewhere in column A, a cell contains the text "sales". Within a macro I want to insert 3 rows above the row that has "sales" in it. Is this possible? TIA Matt |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
One way:
Public Sub InsertAboveSales() Dim rFound As Range Set rFound = Columns(1).Find( _ What:="sales", _ LookIn:=xlValues, _ LookAt:=xlWhole, _ MatchCase:=False) If Not rFound Is Nothing Then _ rFound.Resize(3, 1).EntireRow.Insert End Sub In article , (Matt B) wrote: Hi, Somewhere in column A, a cell contains the text "sales". Within a macro I want to insert 3 rows above the row that has "sales" in it. Is this possible? TIA Matt |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Cannot insert worksheet in exel - not available in insert menu | Excel Worksheet Functions | |||
insert row / insert column command buttons | Excel Worksheet Functions | |||
How can I insert a date with an icon (calendar) insert | Excel Discussion (Misc queries) | |||
Can I auto insert a worksheet when I insert a value in a cell. | Excel Worksheet Functions | |||
Insert Next? Or insert a variable number of records...how? | Excel Discussion (Misc queries) |