A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Excel » Worksheet Functions
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Adding a blank row after a new record changes in excel



 
 
Thread Tools Display Modes
  #1  
Old August 8th, 2008, 12:06 AM posted to microsoft.public.excel.worksheet.functions
Skyblue
external usenet poster
 
Posts: 1
Default 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...
  #2  
Old August 8th, 2008, 04:24 AM posted to microsoft.public.excel.worksheet.functions
Gord Dibben
external usenet poster
 
Posts: 20,252
Default 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...


 




Thread Tools
Display Modes

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

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 10:49 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.