$$Excel-Macros$$ Insert Row after Change in Value in a Selection

2011-02-22 Thread Jacob
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 appre

Re: $$Excel-Macros$$ Insert Row after Change in Value in a Selection

2011-02-22 Thread ashish koul
Sub () Dim i, j, k, z As Long z = 1 ' change column name here if u want to x = "a" Range(x & "65356").Select Selection.End(xlUp).Select k = ActiveCell.Row For i = k To 1 Step -1 If LCase(Range(x & i).Text) <> LCase(Range(x & i - 1).Text) Then Range(x & i).Select

Re: $$Excel-Macros$$ Insert Row after Change in Value in a Selection

2011-02-22 Thread ashish koul
try this one Sub () 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

RE: $$Excel-Macros$$ Insert Row after Change in Value in a Selection

2011-02-23 Thread Omar
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

Re: $$Excel-Macros$$ Insert Row after Change in Value in a Selection

2011-02-23 Thread Paul Schreiner
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: Wedne

Re: $$Excel-Macros$$ Insert Row after Change in Value in a Selection

2011-02-23 Thread rakesh kumar
> > *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 > Select

RE: $$Excel-Macros$$ Insert Row after Change in Value in a Selection

2011-02-23 Thread Omar
el-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 () Dim i, j, k, z A

Re: $$Excel-Macros$$ Insert Row after Change in Value in a Selection

2011-02-23 Thread Jacob
This is what I ended up using. Take in mind I was looking in column B. Work great. Thanks for all your help and suggestions and getting back so fast. Sub InsertRowChange() Dim i, j, k, z As Long k = Range("b65356").End(xlUp).Row Debug.Print k For i = k To 2 Step -1 If Cells(i, 2).T

Re: $$Excel-Macros$$ Insert Row after Change in Value in a Selection

2011-02-23 Thread ashish koul
@omar - try this Sub InsertRowChange() Dim i, j, k, z As Long k = Range("a65356").End(xlUp).Row Debug.Print k For i = k To 2 Step -1 If Not IsEmpty(Cells(i, 1)) And Not IsEmpty(Cells(i - 1, 1)) Then If Cells(i, 1).Text <> Cells(i - 1, 1).Text Then Range("a" & i).Select Selection.

RE: $$Excel-Macros$$ Insert Row after Change in Value in a Selection

2011-02-24 Thread Omar
PERFICT IT IS WORKING VERY GOOD THANKS ASHISH KOUL From: excel-macros@googlegroups.com [mailto:excel-macros@googlegroups.com] On Behalf Of ashish koul Sent: Thursday, February 24, 2011 8:47 AM To: excel-macros@googlegroups.com Subject: Re: $$Excel-Macros$$ Insert Row after Change in Value