Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default Insert a Row

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,885
Default Insert a Row

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default Insert a Row

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Cannot insert worksheet in exel - not available in insert menu pedro39 Excel Worksheet Functions 1 July 24th 08 12:09 PM
insert row / insert column command buttons fairgreen Excel Worksheet Functions 1 October 29th 07 02:41 PM
How can I insert a date with an icon (calendar) insert Alfredo Mederico[_2_] Excel Discussion (Misc queries) 4 September 21st 07 01:20 AM
Can I auto insert a worksheet when I insert a value in a cell. iainc Excel Worksheet Functions 0 April 27th 06 08:37 AM
Insert Next? Or insert a variable number of records...how? Tom MacKay Excel Discussion (Misc queries) 0 April 20th 06 10:44 PM


All times are GMT +1. The time now is 02:56 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"