ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Insert lines at each change in value (https://www.excelbanter.com/excel-discussion-misc-queries/122386-insert-lines-each-change-value.html)

LisaVH

Insert lines at each change in value
 
I need to insert a line at each change in "property Number" in a very long
list of data. Can I set it up to automatically insert a line at each change
(like subtotal, but without the subtotal data)?

Zone

Insert lines at each change in value
 
Lisa, How about this? Copy the sub into a standard module and run it.
It assumes you want to work with the active worksheet. It also
assumes that your property numbers are in column A and that you don't
want to look any higher than row 2. HTH, James

Sub InsertAtChange()
Dim r As Long
For r = Cells(65536, "a").End(xlUp).Row To 3 Step -1
If Cells(r, "a") < "" And Cells(r, "a") < Cells(r - 1, "a")
Then
Rows(r).EntireRow.Insert
End If
Next r
End Sub

LisaVH wrote:
I need to insert a line at each change in "property Number" in a very long
list of data. Can I set it up to automatically insert a line at each change
(like subtotal, but without the subtotal data)?



LisaVH

Insert lines at each change in value
 
Thank You!

"Zone" wrote:

Lisa, How about this? Copy the sub into a standard module and run it.
It assumes you want to work with the active worksheet. It also
assumes that your property numbers are in column A and that you don't
want to look any higher than row 2. HTH, James

Sub InsertAtChange()
Dim r As Long
For r = Cells(65536, "a").End(xlUp).Row To 3 Step -1
If Cells(r, "a") < "" And Cells(r, "a") < Cells(r - 1, "a")
Then
Rows(r).EntireRow.Insert
End If
Next r
End Sub

LisaVH wrote:
I need to insert a line at each change in "property Number" in a very long
list of data. Can I set it up to automatically insert a line at each change
(like subtotal, but without the subtotal data)?




Zone

Insert lines at each change in value
 
Glad it worked for you. James
LisaVH wrote:
Thank You!

"Zone" wrote:

Lisa, How about this? Copy the sub into a standard module and run it.
It assumes you want to work with the active worksheet. It also
assumes that your property numbers are in column A and that you don't
want to look any higher than row 2. HTH, James

Sub InsertAtChange()
Dim r As Long
For r = Cells(65536, "a").End(xlUp).Row To 3 Step -1
If Cells(r, "a") < "" And Cells(r, "a") < Cells(r - 1, "a")
Then
Rows(r).EntireRow.Insert
End If
Next r
End Sub

LisaVH wrote:
I need to insert a line at each change in "property Number" in a very long
list of data. Can I set it up to automatically insert a line at each change
(like subtotal, but without the subtotal data)?






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

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