Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 56
Default Macro to Insert Rows After a given Text in Col A

Hello All,
I am using Office XP and have this macro from the NG. I have a long list of
data in Column A. This macro inserts a blank row (after) looking up the
text in A1 viz "Membership "

How can I change it to insert a blank row (before) the word Membership in
all the rows.

Sub InsertRows()
Dim cRows As Long
Dim i As Integer

For i = Cells(Rows.Count, "A").End(xlUp).Row To 1 Step -1
If Left(Cells(i, "A"), 11) = "Membership " Then
Cells(i + 1, "A").EntireRow.Insert
End If
Next i
End Sub

TIA
Rashid


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Macro to Insert Rows After a given Text in Col A

Sub InsertRows()
Dim cRows As Long
Dim i As Integer

For i = Cells(Rows.Count, "A").End(xlUp).Row To 1 Step -1
If Left(Cells(i, "A"), 11) = "Membership " Then
Cells(i , "A").EntireRow.Insert
End If
Next i
End Sub


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Rashid Khan" wrote in message
...
Hello All,
I am using Office XP and have this macro from the NG. I have a long list

of
data in Column A. This macro inserts a blank row (after) looking up the
text in A1 viz "Membership "

How can I change it to insert a blank row (before) the word Membership in
all the rows.

Sub InsertRows()
Dim cRows As Long
Dim i As Integer

For i = Cells(Rows.Count, "A").End(xlUp).Row To 1 Step -1
If Left(Cells(i, "A"), 11) = "Membership " Then
Cells(i + 1, "A").EntireRow.Insert
End If
Next i
End Sub

TIA
Rashid




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 634
Default Macro to Insert Rows After a given Text in Col A

Just lose the + 1 in the 'Cells(i + 1, "A").EntireRow.Insert' line

Sub InsertRows()
Dim cRows As Long
Dim i As Integer

For i = Cells(Rows.Count, "A").End(xlUp).Row To 1 Step -1
If Left(Cells(i, "A"), 11) = "Membership " Then
Cells(i, "A").EntireRow.Insert
End If
Next i
End Sub

--
Regards
Ken....................... Microsoft MVP - Excel
Sys Spec - Win XP Pro / XL 97/00/02/03

----------------------------------------------------------------------------
It's easier to beg forgiveness than ask permission :-)
----------------------------------------------------------------------------



"Rashid Khan" wrote in message
...
Hello All,
I am using Office XP and have this macro from the NG. I have a long list of
data in Column A. This macro inserts a blank row (after) looking up the
text in A1 viz "Membership "

How can I change it to insert a blank row (before) the word Membership in
all the rows.

Sub InsertRows()
Dim cRows As Long
Dim i As Integer

For i = Cells(Rows.Count, "A").End(xlUp).Row To 1 Step -1
If Left(Cells(i, "A"), 11) = "Membership " Then
Cells(i + 1, "A").EntireRow.Insert
End If
Next i
End Sub

TIA
Rashid




---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.726 / Virus Database: 481 - Release Date: 22/07/2004


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 56
Default Thanks Macro to Insert Rows After a given Text in Col A

Hello Bob and Ken,
Thank you both for your help. It works fine.
Rashid
"Ken Wright" wrote in message
...
Just lose the + 1 in the 'Cells(i + 1, "A").EntireRow.Insert' line

Sub InsertRows()
Dim cRows As Long
Dim i As Integer

For i = Cells(Rows.Count, "A").End(xlUp).Row To 1 Step -1
If Left(Cells(i, "A"), 11) = "Membership " Then
Cells(i, "A").EntireRow.Insert
End If
Next i
End Sub

--
Regards
Ken....................... Microsoft MVP - Excel
Sys Spec - Win XP Pro / XL 97/00/02/03

--------------------------------------------------------------------------

--
It's easier to beg forgiveness than ask permission :-)
--------------------------------------------------------------------------

--



"Rashid Khan" wrote in message
...
Hello All,
I am using Office XP and have this macro from the NG. I have a long list

of
data in Column A. This macro inserts a blank row (after) looking up the
text in A1 viz "Membership "

How can I change it to insert a blank row (before) the word Membership

in
all the rows.

Sub InsertRows()
Dim cRows As Long
Dim i As Integer

For i = Cells(Rows.Count, "A").End(xlUp).Row To 1 Step -1
If Left(Cells(i, "A"), 11) = "Membership " Then
Cells(i + 1, "A").EntireRow.Insert
End If
Next i
End Sub

TIA
Rashid




---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.726 / Virus Database: 481 - Release Date: 22/07/2004




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 634
Default Thanks Macro to Insert Rows After a given Text in Col A

You're welcome

--
Regards
Ken....................... Microsoft MVP - Excel
Sys Spec - Win XP Pro / XL 97/00/02/03

----------------------------------------------------------------------------
It's easier to beg forgiveness than ask permission :-)
----------------------------------------------------------------------------
<snip


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.726 / Virus Database: 481 - Release Date: 22/07/2004




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
Text to Rows and then Insert Blank Rows [email protected] Excel Discussion (Misc queries) 1 December 20th 08 04:23 PM
Insert rows macro. Johnny Excel Discussion (Misc queries) 2 November 13th 07 08:38 PM
asking again, macro to insert rows Luke Excel Worksheet Functions 12 September 18th 05 06:32 PM
Insert Rows Macro Todd Excel Programming 4 April 2nd 04 09:48 PM
macro to insert rows. Todd[_5_] Excel Programming 2 September 27th 03 11:09 PM


All times are GMT +1. The time now is 11:04 PM.

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"