If you're saying that the first time, it inserts a blank row,
but he second time you run it, it adds a second blank row, then
yes, it would, because it's comparing the blank line to a line with a value.
Since they are not equal, it adds another blank line.

You may need to change your IF statement to:
If ((Sheets(1).Cells(i,1).Text <> "") _
and (Sheets(1).Cells(i-1,1).Text <> "") _
and (Sheets(1).Cells(i-1,1).Text <> _
     Sheets(1).Cells(i,1).Text)) then

Paul



________________________________
From: Omar <omar27...@gmail.com>
To: excel-macros@googlegroups.com
Sent: Wed, February 23, 2011 3:21:43 AM
Subject: RE: $$Excel-Macros$$ Insert Row after Change in Value in a Selection


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
>akoul.wordpress.com
>My Linkedin Profile
> 
>PBefore printing, think about the environment.
> 
> 



-- 
Regards
 
Ashish Koul
akoul.blogspot.com
akoul.wordpress.com
My Linkedin Profile
 
PBefore 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

-- 
----------------------------------------------------------------------------------
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