Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1
Default Auto insert a blank row above the current row based on a cell val.

I would like to automatically insert a blank row in a spreadsheet everytime
the cell value in a particular column changes. The blank row should appear
above the row with the new value.
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1,805
Default Auto insert a blank row above the current row based on a cell val.

If you want to test for change in Col A then
Private Sub Worksheet_Change(ByVal Target As Range)
If Left(Target.Address, 2) = "$A" Then ' replace A with your column
Target.EntireRow.Insert
End If
End Sub


"mattwill" wrote:

I would like to automatically insert a blank row in a spreadsheet everytime
the cell value in a particular column changes. The blank row should appear
above the row with the new value.

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 22,906
Default Auto insert a blank row above the current row based on a cell val.

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

The particular column in this code would be column A(1)

Edit to suit


Gord Dibben MS Excel MVP


On Thu, 6 Nov 2008 11:05:01 -0800, mattwill
wrote:

I would like to automatically insert a blank row in a spreadsheet everytime
the cell value in a particular column changes. The blank row should appear
above the row with the new value.


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Auto insert of blank lines Robert Excel Discussion (Misc queries) 5 November 28th 07 10:32 PM
How can I check a cell for current date and insert it if blank? Don K New Users to Excel 3 September 29th 06 02:46 PM
Insert Criteria Based on Current Month Mark Jackson Excel Worksheet Functions 3 May 19th 06 03:16 PM
Auto insert new row after current row filled in Capsaisin Excel Discussion (Misc queries) 1 May 18th 06 11:46 PM
auto insert blank line Little pete Excel Discussion (Misc queries) 4 August 29th 05 09:48 PM


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

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

About Us

"It's about Microsoft Excel"