Just add add the following to the condition

    If Sheets(1).Cells(i, 1).Text <> Sheets(1).Cells(i - 1, 1).Text  and
Len( Sheets(1).Cells(i - 1, 1).Text) > 0 Then

On Wed, Feb 23, 2011 at 1:51 PM, Omar <omar27...@gmail.com> wrote:

> When we run macro again it insert two blank lines
>
>
>
>
>
> *From:* excel-macros@googlegroups.com [mailto:
> excel-macros@googlegroups.com] *On Behalf Of *ashish koul
> *Sent:* Wednesday, February 23, 2011 6:24 AM
> *To:* excel-macros@googlegroups.com
> *Subject:* Re: $$Excel-Macros$$ Insert Row after Change in Value in a
> Selection
>
>
>
> try this one
>
>
>
> Sub aaaaaaaa()
>
>
> Dim i, j, k, z As Long
>
> k = Sheets(1).Range("a65356").End(xlUp).Row
>
>    For i = k To 2 Step -1
>              If Sheets(1).Cells(i, 1).Text <> Sheets(1).Cells(i - 1,
> 1).Text Then
>
>    Range("a" & i).Select
>
>    Selection.EntireRow.Insert
>
>     End If
>
>   Next i
>
>
> Cells(1, 1).Select
>
>
> End Sub
>
> On Wed, Feb 23, 2011 at 7:38 AM, Jacob <app...@gmail.com> wrote:
>
> I have a range where I want to insert a row when the data changes.
> Example Column B
>
> xyz
> xyz
> xyz
> yyz
> yyz
> yyz
> yyz
> yyz
> yyz
> zyx
> zyx
> zyx
> zyx
> zyx
> zyx
>
> I want to insert a row between xyz and yyz.  Also between yyz and
> zyx.   I need am trying to find / write it using VBA.  Any help would
> be greatley appreciated.
>
> Thanks,
>
> Jacob
>
> --
>
> ----------------------------------------------------------------------------------
> Some important links for excel users:
> 1. Follow us on TWITTER for tips tricks and links :
> http://twitter.com/exceldailytip
> 2. Join our LinkedIN group @ http://www.linkedin.com/groups?gid=1871310
> 3. Excel tutorials at http://www.excel-macros.blogspot.com
> 4. Learn VBA Macros at http://www.quickvba.blogspot.com
> 5. Excel Tips and Tricks at http://exceldailytip.blogspot.com
>
> To post to this group, send email to excel-macros@googlegroups.com
>
> <><><><><><><><><><><><><><><><><><><><><><>
> Like our page on facebook , Just follow below link
> http://www.facebook.com/discussexcel
>
>
>
> --
>
> *Regards*
>
> * *
>
> *Ashish Koul*
>
> *akoul*.*blogspot*.com <http://akoul.blogspot.com/>
>
> *akoul*.wordpress.com <http://akoul.wordpress.com/>
>
> My Linkedin Profile <http://in.linkedin.com/pub/ashish-koul/10/400/830>
>
>
>
> P Before printing, think about the environment.
>
>
>
>
>
>
>
>
> --
>
> *Regards*
>
> * *
>
> *Ashish Koul*
>
> *akoul*.*blogspot*.com <http://akoul.blogspot.com/>
>
> *akoul*.wordpress.com <http://akoul.wordpress.com/>
>
> My Linkedin Profile <http://in.linkedin.com/pub/ashish-koul/10/400/830>
>
>
>
> P Before printing, think about the environment.
>
>
>
>
>
> --
>
> ----------------------------------------------------------------------------------
> Some important links for excel users:
> 1. Follow us on TWITTER for tips tricks and links :
> http://twitter.com/exceldailytip
> 2. Join our LinkedIN group @ http://www.linkedin.com/groups?gid=1871310
> 3. Excel tutorials at http://www.excel-macros.blogspot.com
> 4. Learn VBA Macros at http://www.quickvba.blogspot.com
> 5. Excel Tips and Tricks at http://exceldailytip.blogspot.com
>
> To post to this group, send email to excel-macros@googlegroups.com
>
> <><><><><><><><><><><><><><><><><><><><><><>
> Like our page on facebook , Just follow below link
> http://www.facebook.com/discussexcel
>
> --
>
> ----------------------------------------------------------------------------------
> Some important links for excel users:
> 1. Follow us on TWITTER for tips tricks and links :
> http://twitter.com/exceldailytip
> 2. Join our LinkedIN group @ http://www.linkedin.com/groups?gid=1871310
> 3. Excel tutorials at http://www.excel-macros.blogspot.com
> 4. Learn VBA Macros at http://www.quickvba.blogspot.com
> 5. Excel Tips and Tricks at http://exceldailytip.blogspot.com
>
> To post to this group, send email to excel-macros@googlegroups.com
>
> <><><><><><><><><><><><><><><><><><><><><><>
> Like our page on facebook , Just follow below link
> http://www.facebook.com/discussexcel
>



-- 
  Rakesh kumar khowal
 +91 9540084660
 +91 9868532105

-- 
----------------------------------------------------------------------------------
Some important links for excel users:
1. Follow us on TWITTER for tips tricks and links : 
http://twitter.com/exceldailytip
2. Join our LinkedIN group @ http://www.linkedin.com/groups?gid=1871310
3. Excel tutorials at http://www.excel-macros.blogspot.com
4. Learn VBA Macros at http://www.quickvba.blogspot.com
5. Excel Tips and Tricks at http://exceldailytip.blogspot.com
 
To post to this group, send email to excel-macros@googlegroups.com

<><><><><><><><><><><><><><><><><><><><><><>
Like our page on facebook , Just follow below link
http://www.facebook.com/discussexcel

Reply via email to