ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   new (https://www.excelbanter.com/excel-discussion-misc-queries/169525-new.html)

De

new
 
Insert row at each change of surname in column
--
De

Don Guillett

new
 
Sub insertrowifnamechg()
mc = "a"
For i = Cells(Rows.Count, mc).End(xlUp).Row To 2 Step -1
If Cells(i - 1, mc) < Cells(i, mc) Then Rows(i).Insert
Next i
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"De" wrote in message
...
Insert row at each change of surname in column
--
De



Stephen[_2_]

new
 
Subtotal

"De" wrote in message
...
Insert row at each change of surname in column
--
De




De

new
 
I can't see how I can insert a row using subtotals; the only option seems to
be page break. Is there a way to insert a row? Many thanks,
--
De


"Stephen" wrote:

Subtotal

"De" wrote in message
...
Insert row at each change of surname in column
--
De





Stephen[_2_]

new
 
I assumed you wanted to do something with the inserted rows, so I was
thinking of
Data Subtotals
which allows you to specify what you want to do on the inserted rows (sum,
average, etc.)

"De" wrote in message
...
I can't see how I can insert a row using subtotals; the only option seems
to
be page break. Is there a way to insert a row? Many thanks,
--
De


"Stephen" wrote:

Subtotal

"De" wrote in message
...
Insert row at each change of surname in column
--
De







De

new
 
Showing my ignorance but is this a macro? Because it doesn't look like it
will go on the formula bar.
--
De


"Don Guillett" wrote:

Sub insertrowifnamechg()
mc = "a"
For i = Cells(Rows.Count, mc).End(xlUp).Row To 2 Step -1
If Cells(i - 1, mc) < Cells(i, mc) Then Rows(i).Insert
Next i
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"De" wrote in message
...
Insert row at each change of surname in column
--
De




De

new
 
Many thanks for this but is is a macro? I tried it as both a macro and in
the formula bar but I'm not confident with macros so I might not have got it
right.
--
De


"Don Guillett" wrote:

Sub insertrowifnamechg()
mc = "a"
For i = Cells(Rows.Count, mc).End(xlUp).Row To 2 Step -1
If Cells(i - 1, mc) < Cells(i, mc) Then Rows(i).Insert
Next i
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"De" wrote in message
...
Insert row at each change of surname in column
--
De




Don Guillett

new
 

A formula could not insert a row. This is a macro
If you're new to macros, you may want to read David McRitchie's intro
at:
http://www.mvps.org/dmcritchie/excel/getstarted.htm

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"De" wrote in message
...
Many thanks for this but is is a macro? I tried it as both a macro and in
the formula bar but I'm not confident with macros so I might not have got
it
right.
--
De


"Don Guillett" wrote:

Sub insertrowifnamechg()
mc = "a"
For i = Cells(Rows.Count, mc).End(xlUp).Row To 2 Step -1
If Cells(i - 1, mc) < Cells(i, mc) Then Rows(i).Insert
Next i
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"De" wrote in message
...
Insert row at each change of surname in column
--
De





De

new
 
Many tks for the help.
--
De


"Don Guillett" wrote:

Sub insertrowifnamechg()
mc = "a"
For i = Cells(Rows.Count, mc).End(xlUp).Row To 2 Step -1
If Cells(i - 1, mc) < Cells(i, mc) Then Rows(i).Insert
Next i
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"De" wrote in message
...
Insert row at each change of surname in column
--
De





All times are GMT +1. The time now is 12:50 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com