ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Adding a blank row after a new record changes in excel (https://www.excelbanter.com/excel-worksheet-functions/198058-adding-blank-row-after-new-record-changes-excel.html)

Skyblue

Adding a blank row after a new record changes in excel
 
I need to add a blank row to excel for every time the customer number
changes. I have a worksheet that contains customer numbers and invoices. So
sometimes I have one customer for one invoice, most of the times, I have one
customer for 5 to 10 invoices. So I need to add a blank row after a customer
number changes. Please help...

Gord Dibben

Adding a blank row after a new record changes in excel
 
Sub InsertRow_At_Change()
'Sandy Mann July 1st, 2007
Dim LastRow As Long
Dim X As Long
LastRow = Cells(Rows.Count, 1).End(xlUp).Row
Application.ScreenUpdating = False

For X = LastRow To 3 Step -1
If Cells(X, 1).Value < Cells(X - 1, 1).Value Then
If Cells(X, 1).Value < "" Then
If Cells(X - 1, 1).Value < "" Then
Cells(X, 1).entirerow.Insert Shift:=xlDown
End If
End If
End If
Next X

Application.ScreenUpdating = True
End Sub

Assumes customer numbers are in column A.

Adjust to suit your case.


Gord Dibben MS Excel MVP

On Thu, 7 Aug 2008 16:06:05 -0700, Skyblue
wrote:

I need to add a blank row to excel for every time the customer number
changes. I have a worksheet that contains customer numbers and invoices. So
sometimes I have one customer for one invoice, most of the times, I have one
customer for 5 to 10 invoices. So I need to add a blank row after a customer
number changes. Please help...




All times are GMT +1. The time now is 03:01 PM.

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