PC Review


Reply
Thread Tools Rate Thread

asking again, macro to insert rows

 
 
=?Utf-8?B?THVrZQ==?=
Guest
Posts: n/a
 
      18th Sep 2005
Example:
My sheet needs to insert a blank row under a number everytime it changes.
The column "C" may have 20 or so rows with the number 10 for example, the
next five might be the number 8, I need a row between the last number ten and
the first number eight. This may be repeated many times through the
spreadsheet.
As well, the adjacent columns "D" & "E" are the same as described above.
all 3 columns are continuous ie:
C D E
8
8
8
8
20
20
20
20
10
10
10
5
5
9
9
9
12
12
12
therefore I need to insert a row between 8 & 20, 20 & 10, 10 & 5 and etc.
I hope that I have articulated this well enough.

I've tried the following but it is for only one column and I assume it's the
reason I get a sytax error at:
cells(nr,1.select

sub blnkentery()
nr=Application.WorksheetFunction.counta("A:A")
for r = nr to 2 step -1
cells(nr,1.select
if cells(nr,1) <> cells(nr-1,1) then Selection.EntireRow.Insert
next r
end sub

please help
Thank You for your time
Luke

 
Reply With Quote
 
 
 
 
PY & Associates
Guest
Posts: n/a
 
      18th Sep 2005
> cells(nr,1.select
close bracket missing

loop columns 2 and 3

"Luke" <(E-Mail Removed)> wrote in message
news:9A6C8FD9-2E84-4C2E-AD63-(E-Mail Removed)...
> Example:
> My sheet needs to insert a blank row under a number everytime it changes.
> The column "C" may have 20 or so rows with the number 10 for example, the
> next five might be the number 8, I need a row between the last number ten

and
> the first number eight. This may be repeated many times through the
> spreadsheet.
> As well, the adjacent columns "D" & "E" are the same as described above.
> all 3 columns are continuous ie:
> C D E
> 8
> 8
> 8
> 8
> 20
> 20
> 20
> 20
> 10
> 10
> 10
> 5
> 5
> 9
> 9
> 9
> 12
> 12
> 12
> therefore I need to insert a row between 8 & 20, 20 & 10, 10 & 5 and etc.
> I hope that I have articulated this well enough.
>
> I've tried the following but it is for only one column and I assume it's

the
> reason I get a sytax error at:
> cells(nr,1.select
>
> sub blnkentery()
> nr=Application.WorksheetFunction.counta("A:A")
> for r = nr to 2 step -1
> cells(nr,1.select
> if cells(nr,1) <> cells(nr-1,1) then Selection.EntireRow.Insert
> next r
> end sub
>
> please help
> Thank You for your time
> Luke
>



 
Reply With Quote
 
PY & Associates
Guest
Posts: n/a
 
      18th Sep 2005
I suggest you get the biggest of the row number of the three columns,
loop all rows up from biggest row number
if cell cn<>cn-1 or dn<>dn-1or en<>en-1 then insert one row


"Luke" <(E-Mail Removed)> wrote in message
news:9A6C8FD9-2E84-4C2E-AD63-(E-Mail Removed)...
> Example:
> My sheet needs to insert a blank row under a number everytime it changes.
> The column "C" may have 20 or so rows with the number 10 for example, the
> next five might be the number 8, I need a row between the last number ten

and
> the first number eight. This may be repeated many times through the
> spreadsheet.
> As well, the adjacent columns "D" & "E" are the same as described above.
> all 3 columns are continuous ie:
> C D E
> 8
> 8
> 8
> 8
> 20
> 20
> 20
> 20
> 10
> 10
> 10
> 5
> 5
> 9
> 9
> 9
> 12
> 12
> 12
> therefore I need to insert a row between 8 & 20, 20 & 10, 10 & 5 and etc.
> I hope that I have articulated this well enough.
>
> I've tried the following but it is for only one column and I assume it's

the
> reason I get a sytax error at:
> cells(nr,1.select
>
> sub blnkentery()
> nr=Application.WorksheetFunction.counta("A:A")
> for r = nr to 2 step -1
> cells(nr,1.select
> if cells(nr,1) <> cells(nr-1,1) then Selection.EntireRow.Insert
> next r
> end sub
>
> please help
> Thank You for your time
> Luke
>



 
Reply With Quote
 
=?Utf-8?B?THVrZQ==?=
Guest
Posts: n/a
 
      18th Sep 2005
Okay on the bracket but I don't understand "loop columns 2 and 3" could you
elaborate? I don't know VB that well.
Thank you
Luke

"PY & Associates" wrote:

> > cells(nr,1.select

> close bracket missing
>
> loop columns 2 and 3
>
> "Luke" <(E-Mail Removed)> wrote in message
> news:9A6C8FD9-2E84-4C2E-AD63-(E-Mail Removed)...
> > Example:
> > My sheet needs to insert a blank row under a number everytime it changes.
> > The column "C" may have 20 or so rows with the number 10 for example, the
> > next five might be the number 8, I need a row between the last number ten

> and
> > the first number eight. This may be repeated many times through the
> > spreadsheet.
> > As well, the adjacent columns "D" & "E" are the same as described above.
> > all 3 columns are continuous ie:
> > C D E
> > 8
> > 8
> > 8
> > 8
> > 20
> > 20
> > 20
> > 20
> > 10
> > 10
> > 10
> > 5
> > 5
> > 9
> > 9
> > 9
> > 12
> > 12
> > 12
> > therefore I need to insert a row between 8 & 20, 20 & 10, 10 & 5 and etc.
> > I hope that I have articulated this well enough.
> >
> > I've tried the following but it is for only one column and I assume it's

> the
> > reason I get a sytax error at:
> > cells(nr,1.select
> >
> > sub blnkentery()
> > nr=Application.WorksheetFunction.counta("A:A")
> > for r = nr to 2 step -1
> > cells(nr,1.select
> > if cells(nr,1) <> cells(nr-1,1) then Selection.EntireRow.Insert
> > next r
> > end sub
> >
> > please help
> > Thank You for your time
> > Luke
> >

>
>
>

 
Reply With Quote
 
=?Utf-8?B?THVrZQ==?=
Guest
Posts: n/a
 
      18th Sep 2005
PY & Associates,
Thanks for that. I guess now I am trying to figure out how that would be
entered into VB as I don't know VB well enough :

sub blnkentery()
nr=Application.WorksheetFunction.counta("c:c")
for r = nr to 2 step -1
cells(nr,1.select)
if cells(nr,1) <> cells(nr-1,1) then Selection.EntireRow.Insert
next r
end sub

Thank you for your help thus far
Luke


"PY & Associates" wrote:

> I suggest you get the biggest of the row number of the three columns,
> loop all rows up from biggest row number
> if cell cn<>cn-1 or dn<>dn-1or en<>en-1 then insert one row
>
>
> "Luke" <(E-Mail Removed)> wrote in message
> news:9A6C8FD9-2E84-4C2E-AD63-(E-Mail Removed)...
> > Example:
> > My sheet needs to insert a blank row under a number everytime it changes.
> > The column "C" may have 20 or so rows with the number 10 for example, the
> > next five might be the number 8, I need a row between the last number ten

> and
> > the first number eight. This may be repeated many times through the
> > spreadsheet.
> > As well, the adjacent columns "D" & "E" are the same as described above.
> > all 3 columns are continuous ie:
> > C D E
> > 8
> > 8
> > 8
> > 8
> > 20
> > 20
> > 20
> > 20
> > 10
> > 10
> > 10
> > 5
> > 5
> > 9
> > 9
> > 9
> > 12
> > 12
> > 12
> > therefore I need to insert a row between 8 & 20, 20 & 10, 10 & 5 and etc.
> > I hope that I have articulated this well enough.
> >
> > I've tried the following but it is for only one column and I assume it's

> the
> > reason I get a sytax error at:
> > cells(nr,1.select
> >
> > sub blnkentery()
> > nr=Application.WorksheetFunction.counta("A:A")
> > for r = nr to 2 step -1
> > cells(nr,1.select
> > if cells(nr,1) <> cells(nr-1,1) then Selection.EntireRow.Insert
> > next r
> > end sub
> >
> > please help
> > Thank You for your time
> > Luke
> >

>
>
>

 
Reply With Quote
 
Bob Phillips
Guest
Posts: n/a
 
      18th Sep 2005
Sub test()
Dim iLastRow As Long
Dim i As Long

iLastRow = Cells(Rows.Count, "C").End(xlUp).Row
For i = iLastRow - 1 To 2 Step -1
If Cells(i, "C").Value <> Cells(i - 1, "C").Value Then
Rows(i).Insert
End If
Next i

End Sub


--
HTH

Bob Phillips

"Luke" <(E-Mail Removed)> wrote in message
news:9A6C8FD9-2E84-4C2E-AD63-(E-Mail Removed)...
> Example:
> My sheet needs to insert a blank row under a number everytime it changes.
> The column "C" may have 20 or so rows with the number 10 for example, the
> next five might be the number 8, I need a row between the last number ten

and
> the first number eight. This may be repeated many times through the
> spreadsheet.
> As well, the adjacent columns "D" & "E" are the same as described above.
> all 3 columns are continuous ie:
> C D E
> 8
> 8
> 8
> 8
> 20
> 20
> 20
> 20
> 10
> 10
> 10
> 5
> 5
> 9
> 9
> 9
> 12
> 12
> 12
> therefore I need to insert a row between 8 & 20, 20 & 10, 10 & 5 and etc.
> I hope that I have articulated this well enough.
>
> I've tried the following but it is for only one column and I assume it's

the
> reason I get a sytax error at:
> cells(nr,1.select
>
> sub blnkentery()
> nr=Application.WorksheetFunction.counta("A:A")
> for r = nr to 2 step -1
> cells(nr,1.select
> if cells(nr,1) <> cells(nr-1,1) then Selection.EntireRow.Insert
> next r
> end sub
>
> please help
> Thank You for your time
> Luke
>



 
Reply With Quote
 
Bob Phillips
Guest
Posts: n/a
 
      18th Sep 2005
Sorry, I posted the wrong version. Try this

Sub test()
Dim iLastRow As Long
Dim i As Long

iLastRow = Cells(Rows.Count, "C").End(xlUp).Row
For i = 1 To iLastRow
If Cells(i, "C").Value <> "" Then
Cells(i, "F").Value = Cells(i, "C").Value
ElseIf Cells(i, "D").Value <> "" Then
Cells(i, "F").Value = Cells(i, "D").Value
Else
Cells(i, "F").Value = Cells(i, "E").Value
End If
Next i

For i = iLastRow - 1 To 2 Step -1
If Cells(i, "F").Value <> Cells(i - 1, "F").Value Then
Rows(i).Insert
End If
Next i

Range("F1").Resize(iLastRow).ClearContents

End Sub


--
HTH

Bob Phillips

"Bob Phillips" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> Sub test()
> Dim iLastRow As Long
> Dim i As Long
>
> iLastRow = Cells(Rows.Count, "C").End(xlUp).Row
> For i = iLastRow - 1 To 2 Step -1
> If Cells(i, "C").Value <> Cells(i - 1, "C").Value Then
> Rows(i).Insert
> End If
> Next i
>
> End Sub
>
>
> --
> HTH
>
> Bob Phillips
>
> "Luke" <(E-Mail Removed)> wrote in message
> news:9A6C8FD9-2E84-4C2E-AD63-(E-Mail Removed)...
> > Example:
> > My sheet needs to insert a blank row under a number everytime it

changes.
> > The column "C" may have 20 or so rows with the number 10 for example,

the
> > next five might be the number 8, I need a row between the last number

ten
> and
> > the first number eight. This may be repeated many times through the
> > spreadsheet.
> > As well, the adjacent columns "D" & "E" are the same as described above.
> > all 3 columns are continuous ie:
> > C D E
> > 8
> > 8
> > 8
> > 8
> > 20
> > 20
> > 20
> > 20
> > 10
> > 10
> > 10
> > 5
> > 5
> > 9
> > 9
> > 9
> > 12
> > 12
> > 12
> > therefore I need to insert a row between 8 & 20, 20 & 10, 10 & 5 and

etc.
> > I hope that I have articulated this well enough.
> >
> > I've tried the following but it is for only one column and I assume it's

> the
> > reason I get a sytax error at:
> > cells(nr,1.select
> >
> > sub blnkentery()
> > nr=Application.WorksheetFunction.counta("A:A")
> > for r = nr to 2 step -1
> > cells(nr,1.select
> > if cells(nr,1) <> cells(nr-1,1) then Selection.EntireRow.Insert
> > next r
> > end sub
> >
> > please help
> > Thank You for your time
> > Luke
> >

>
>



 
Reply With Quote
 
PY & Associates
Guest
Posts: n/a
 
      18th Sep 2005
Bob's program is great.
I was think of this

Sub t()
rowc = Range("A65536").End(xlUp).Row
rowd = Range("B65536").End(xlUp).Row
rowe = Range("C65536").End(xlUp).Row
lrow = Application.WorksheetFunction.Max(rowc, rowd, rowe)
For i = lrow To 3 Step -1
If Cells(i, 1) <> Cells(i - 1, 1) Or Cells(i, 2) <> Cells(i - 1, 2) _
Or Cells(i, 3) <> Cells(i - 1, 3) Then Cells(i, 1).EntireRow.Insert
Next i
End Sub

"Bob Phillips" <(E-Mail Removed)> wrote in message
news:%23c%(E-Mail Removed)...
> Sorry, I posted the wrong version. Try this
>
> Sub test()
> Dim iLastRow As Long
> Dim i As Long
>
> iLastRow = Cells(Rows.Count, "C").End(xlUp).Row
> For i = 1 To iLastRow
> If Cells(i, "C").Value <> "" Then
> Cells(i, "F").Value = Cells(i, "C").Value
> ElseIf Cells(i, "D").Value <> "" Then
> Cells(i, "F").Value = Cells(i, "D").Value
> Else
> Cells(i, "F").Value = Cells(i, "E").Value
> End If
> Next i
>
> For i = iLastRow - 1 To 2 Step -1
> If Cells(i, "F").Value <> Cells(i - 1, "F").Value Then
> Rows(i).Insert
> End If
> Next i
>
> Range("F1").Resize(iLastRow).ClearContents
>
> End Sub
>
>
> --
> HTH
>
> Bob Phillips
>
> "Bob Phillips" <(E-Mail Removed)> wrote in message
> news:%(E-Mail Removed)...
> > Sub test()
> > Dim iLastRow As Long
> > Dim i As Long
> >
> > iLastRow = Cells(Rows.Count, "C").End(xlUp).Row
> > For i = iLastRow - 1 To 2 Step -1
> > If Cells(i, "C").Value <> Cells(i - 1, "C").Value Then
> > Rows(i).Insert
> > End If
> > Next i
> >
> > End Sub
> >
> >
> > --
> > HTH
> >
> > Bob Phillips
> >
> > "Luke" <(E-Mail Removed)> wrote in message
> > news:9A6C8FD9-2E84-4C2E-AD63-(E-Mail Removed)...
> > > Example:
> > > My sheet needs to insert a blank row under a number everytime it

> changes.
> > > The column "C" may have 20 or so rows with the number 10 for example,

> the
> > > next five might be the number 8, I need a row between the last number

> ten
> > and
> > > the first number eight. This may be repeated many times through the
> > > spreadsheet.
> > > As well, the adjacent columns "D" & "E" are the same as described

above.
> > > all 3 columns are continuous ie:
> > > C D E
> > > 8
> > > 8
> > > 8
> > > 8
> > > 20
> > > 20
> > > 20
> > > 20
> > > 10
> > > 10
> > > 10
> > > 5
> > > 5
> > > 9
> > > 9
> > > 9
> > > 12
> > > 12
> > > 12
> > > therefore I need to insert a row between 8 & 20, 20 & 10, 10 & 5 and

> etc.
> > > I hope that I have articulated this well enough.
> > >
> > > I've tried the following but it is for only one column and I assume

it's
> > the
> > > reason I get a sytax error at:
> > > cells(nr,1.select
> > >
> > > sub blnkentery()
> > > nr=Application.WorksheetFunction.counta("A:A")
> > > for r = nr to 2 step -1
> > > cells(nr,1.select
> > > if cells(nr,1) <> cells(nr-1,1) then Selection.EntireRow.Insert
> > > next r
> > > end sub
> > >
> > > please help
> > > Thank You for your time
> > > Luke
> > >

> >
> >

>
>



 
Reply With Quote
 
Bob Phillips
Guest
Posts: n/a
 
      18th Sep 2005
Hi PY,

Yeah that works good too, when adjusted to the OP's ranges, if a bit more
obtuse <g>

Just a couple of comments.

First you need to step back to row 2, just in case it changes between row 1
and row 2.
second, I detest hard coding row count, and evangelise using Rows.Count

Sub t()
Dim lRow As Long
Dim i As Long
lRow = WorksheetFunction.Max(Range("C" & Rows.Count).End(xlUp).Row, _
Range("D" & Rows.Count).End(xlUp).Row, _
Range("E" & Rows.Count).End(xlUp).Row)
For i = lRow To 3 Step -1
If Cells(i, "C") <> Cells(i - 1, "C") Or _
Cells(i, "D") <> Cells(i - 1, "D") Or _
Cells(i, "E") <> Cells(i - 1, "E") Then _
Rows(i).Insert
Next i
End Sub


--
HTH

Bob Phillips

"PY & Associates" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> Bob's program is great.
> I was think of this
>
> Sub t()
> rowc = Range("A65536").End(xlUp).Row
> rowd = Range("B65536").End(xlUp).Row
> rowe = Range("C65536").End(xlUp).Row
> lrow = Application.WorksheetFunction.Max(rowc, rowd, rowe)
> For i = lrow To 3 Step -1
> If Cells(i, 1) <> Cells(i - 1, 1) Or Cells(i, 2) <> Cells(i - 1, 2) _
> Or Cells(i, 3) <> Cells(i - 1, 3) Then Cells(i, 1).EntireRow.Insert
> Next i
> End Sub
>
> "Bob Phillips" <(E-Mail Removed)> wrote in message
> news:%23c%(E-Mail Removed)...
> > Sorry, I posted the wrong version. Try this
> >
> > Sub test()
> > Dim iLastRow As Long
> > Dim i As Long
> >
> > iLastRow = Cells(Rows.Count, "C").End(xlUp).Row
> > For i = 1 To iLastRow
> > If Cells(i, "C").Value <> "" Then
> > Cells(i, "F").Value = Cells(i, "C").Value
> > ElseIf Cells(i, "D").Value <> "" Then
> > Cells(i, "F").Value = Cells(i, "D").Value
> > Else
> > Cells(i, "F").Value = Cells(i, "E").Value
> > End If
> > Next i
> >
> > For i = iLastRow - 1 To 2 Step -1
> > If Cells(i, "F").Value <> Cells(i - 1, "F").Value Then
> > Rows(i).Insert
> > End If
> > Next i
> >
> > Range("F1").Resize(iLastRow).ClearContents
> >
> > End Sub
> >
> >
> > --
> > HTH
> >
> > Bob Phillips
> >
> > "Bob Phillips" <(E-Mail Removed)> wrote in message
> > news:%(E-Mail Removed)...
> > > Sub test()
> > > Dim iLastRow As Long
> > > Dim i As Long
> > >
> > > iLastRow = Cells(Rows.Count, "C").End(xlUp).Row
> > > For i = iLastRow - 1 To 2 Step -1
> > > If Cells(i, "C").Value <> Cells(i - 1, "C").Value Then
> > > Rows(i).Insert
> > > End If
> > > Next i
> > >
> > > End Sub
> > >
> > >
> > > --
> > > HTH
> > >
> > > Bob Phillips
> > >
> > > "Luke" <(E-Mail Removed)> wrote in message
> > > news:9A6C8FD9-2E84-4C2E-AD63-(E-Mail Removed)...
> > > > Example:
> > > > My sheet needs to insert a blank row under a number everytime it

> > changes.
> > > > The column "C" may have 20 or so rows with the number 10 for

example,
> > the
> > > > next five might be the number 8, I need a row between the last

number
> > ten
> > > and
> > > > the first number eight. This may be repeated many times through the
> > > > spreadsheet.
> > > > As well, the adjacent columns "D" & "E" are the same as described

> above.
> > > > all 3 columns are continuous ie:
> > > > C D E
> > > > 8
> > > > 8
> > > > 8
> > > > 8
> > > > 20
> > > > 20
> > > > 20
> > > > 20
> > > > 10
> > > > 10
> > > > 10
> > > > 5
> > > > 5
> > > > 9
> > > > 9
> > > > 9
> > > > 12
> > > > 12
> > > > 12
> > > > therefore I need to insert a row between 8 & 20, 20 & 10, 10 & 5 and

> > etc.
> > > > I hope that I have articulated this well enough.
> > > >
> > > > I've tried the following but it is for only one column and I assume

> it's
> > > the
> > > > reason I get a sytax error at:
> > > > cells(nr,1.select
> > > >
> > > > sub blnkentery()
> > > > nr=Application.WorksheetFunction.counta("A:A")
> > > > for r = nr to 2 step -1
> > > > cells(nr,1.select
> > > > if cells(nr,1) <> cells(nr-1,1) then Selection.EntireRow.Insert
> > > > next r
> > > > end sub
> > > >
> > > > please help
> > > > Thank You for your time
> > > > Luke
> > > >
> > >
> > >

> >
> >

>
>



 
Reply With Quote
 
PY & Associates
Guest
Posts: n/a
 
      18th Sep 2005
Good suggestion.

1 What is OP's ranges please?
2 rows.count or 65536 is purely personal preference.
I choose 65536 because I can see this number;
I most likely cannot remember rows.count;
I am not as young as I want myself to be.
3 we are not sure what the REAL list looks like.
Is C a label, or column label, why cells(nrs,1) is under C?
so loop to 2 or 3 is only our demo how the code works.

We are learning from each other.
Great community.

"Bob Phillips" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> Hi PY,
>
> Yeah that works good too, when adjusted to the OP's ranges, if a bit more
> obtuse <g>
>
> Just a couple of comments.
>
> First you need to step back to row 2, just in case it changes between row

1
> and row 2.
> second, I detest hard coding row count, and evangelise using Rows.Count
>
> Sub t()
> Dim lRow As Long
> Dim i As Long
> lRow = WorksheetFunction.Max(Range("C" & Rows.Count).End(xlUp).Row, _
> Range("D" & Rows.Count).End(xlUp).Row, _
> Range("E" & Rows.Count).End(xlUp).Row)
> For i = lRow To 3 Step -1
> If Cells(i, "C") <> Cells(i - 1, "C") Or _
> Cells(i, "D") <> Cells(i - 1, "D") Or _
> Cells(i, "E") <> Cells(i - 1, "E") Then _
> Rows(i).Insert
> Next i
> End Sub
>
>
> --
> HTH
>
> Bob Phillips
>
> "PY & Associates" <(E-Mail Removed)> wrote in message
> news:%(E-Mail Removed)...
> > Bob's program is great.
> > I was think of this
> >
> > Sub t()
> > rowc = Range("A65536").End(xlUp).Row
> > rowd = Range("B65536").End(xlUp).Row
> > rowe = Range("C65536").End(xlUp).Row
> > lrow = Application.WorksheetFunction.Max(rowc, rowd, rowe)
> > For i = lrow To 3 Step -1
> > If Cells(i, 1) <> Cells(i - 1, 1) Or Cells(i, 2) <> Cells(i - 1, 2) _
> > Or Cells(i, 3) <> Cells(i - 1, 3) Then Cells(i, 1).EntireRow.Insert
> > Next i
> > End Sub
> >
> > "Bob Phillips" <(E-Mail Removed)> wrote in message
> > news:%23c%(E-Mail Removed)...
> > > Sorry, I posted the wrong version. Try this
> > >
> > > Sub test()
> > > Dim iLastRow As Long
> > > Dim i As Long
> > >
> > > iLastRow = Cells(Rows.Count, "C").End(xlUp).Row
> > > For i = 1 To iLastRow
> > > If Cells(i, "C").Value <> "" Then
> > > Cells(i, "F").Value = Cells(i, "C").Value
> > > ElseIf Cells(i, "D").Value <> "" Then
> > > Cells(i, "F").Value = Cells(i, "D").Value
> > > Else
> > > Cells(i, "F").Value = Cells(i, "E").Value
> > > End If
> > > Next i
> > >
> > > For i = iLastRow - 1 To 2 Step -1
> > > If Cells(i, "F").Value <> Cells(i - 1, "F").Value Then
> > > Rows(i).Insert
> > > End If
> > > Next i
> > >
> > > Range("F1").Resize(iLastRow).ClearContents
> > >
> > > End Sub
> > >
> > >
> > > --
> > > HTH
> > >
> > > Bob Phillips
> > >
> > > "Bob Phillips" <(E-Mail Removed)> wrote in message
> > > news:%(E-Mail Removed)...
> > > > Sub test()
> > > > Dim iLastRow As Long
> > > > Dim i As Long
> > > >
> > > > iLastRow = Cells(Rows.Count, "C").End(xlUp).Row
> > > > For i = iLastRow - 1 To 2 Step -1
> > > > If Cells(i, "C").Value <> Cells(i - 1, "C").Value Then
> > > > Rows(i).Insert
> > > > End If
> > > > Next i
> > > >
> > > > End Sub
> > > >
> > > >
> > > > --
> > > > HTH
> > > >
> > > > Bob Phillips
> > > >
> > > > "Luke" <(E-Mail Removed)> wrote in message
> > > > news:9A6C8FD9-2E84-4C2E-AD63-(E-Mail Removed)...
> > > > > Example:
> > > > > My sheet needs to insert a blank row under a number everytime it
> > > changes.
> > > > > The column "C" may have 20 or so rows with the number 10 for

> example,
> > > the
> > > > > next five might be the number 8, I need a row between the last

> number
> > > ten
> > > > and
> > > > > the first number eight. This may be repeated many times through

the
> > > > > spreadsheet.
> > > > > As well, the adjacent columns "D" & "E" are the same as described

> > above.
> > > > > all 3 columns are continuous ie:
> > > > > C D E
> > > > > 8
> > > > > 8
> > > > > 8
> > > > > 8
> > > > > 20
> > > > > 20
> > > > > 20
> > > > > 20
> > > > > 10
> > > > > 10
> > > > > 10
> > > > > 5
> > > > > 5
> > > > > 9
> > > > > 9
> > > > > 9
> > > > > 12
> > > > > 12
> > > > > 12
> > > > > therefore I need to insert a row between 8 & 20, 20 & 10, 10 & 5

and
> > > etc.
> > > > > I hope that I have articulated this well enough.
> > > > >
> > > > > I've tried the following but it is for only one column and I

assume
> > it's
> > > > the
> > > > > reason I get a sytax error at:
> > > > > cells(nr,1.select
> > > > >
> > > > > sub blnkentery()
> > > > > nr=Application.WorksheetFunction.counta("A:A")
> > > > > for r = nr to 2 step -1
> > > > > cells(nr,1.select
> > > > > if cells(nr,1) <> cells(nr-1,1) then Selection.EntireRow.Insert
> > > > > next r
> > > > > end sub
> > > > >
> > > > > please help
> > > > > Thank You for your time
> > > > > Luke
> > > > >
> > > >
> > > >
> > >
> > >

> >
> >

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro to insert Rows marc747@excite.com Microsoft Excel Programming 4 17th Aug 2008 01:00 PM
Insert rows macro leonidas Microsoft Excel Programming 1 24th Jun 2006 12:38 AM
Macro to insert rows The Grinch Microsoft Excel Discussion 7 4th Aug 2005 12:43 PM
Macro insert data, need to insert rows =?Utf-8?B?QnJhZA==?= Microsoft Excel Misc 1 28th May 2004 03:33 PM
Insert Rows Macro =?Utf-8?B?SmFzb24gV2F0dHM=?= Microsoft Excel Programming 19 5th Feb 2004 08:42 PM


Features
 

Advertising
 

Newsgroups
 


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