Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3
Default Function to insert rows on a change in a cell

Is it possible to automatically insert a blank row after a change in a cell
value
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 8,856
Default Function to insert rows on a change in a cell

Not using a function or a formula. You can only do that with an event macro.

Pete

"Subhash" wrote in message
...
Is it possible to automatically insert a blank row after a change in a
cell
value



  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3
Default Function to insert rows on a change in a cell

Thanks Pete

What is an event macro ?





"Pete_UK" wrote:

Not using a function or a formula. You can only do that with an event macro.

Pete

"Subhash" wrote in message
...
Is it possible to automatically insert a blank row after a change in a
cell
value




  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 22,906
Default Function to insert rows on a change in a cell

See Chip Pearson's site for more on event macros.

http://www.cpearson.com/excel/Events.aspx

This would be an example of event code....................

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
Dim num As Integer
num = 1
On Error GoTo stoppit
If Intersect(Target, Me.Range("A1")) Is Nothing Then Exit Sub
Target.Offset(1, 0).Resize(num).EntireRow.Insert
stoppit:
End Sub

When you manually change the data in A1, you will insert a blank row below that.

Right-click on the worksheet tab and "View Code" Copy/paste into that sheet
module.

Alt + q to return to the Excel worksheet window.

BUT...................if your question was to insert a row at every change in
value down a column.

i.e. column A has values of

abc
abc
abc
def
def
def
ghi
ghi
ghi

You want to insert a row at each change you would use a regular macro.

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


Gord Dibben MS Excel MVP


On Tue, 18 Mar 2008 18:34:00 -0700, Subhash
wrote:

Thanks Pete

What is an event macro ?





"Pete_UK" wrote:

Not using a function or a formula. You can only do that with an event macro.

Pete

"Subhash" wrote in message
...
Is it possible to automatically insert a blank row after a change in a
cell
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
How to insert rows based on change in data Leoc Excel Worksheet Functions 2 January 23rd 08 10:12 PM
how do i insert rows in a cell Julia Excel Worksheet Functions 1 November 20th 06 10:15 AM
how to change the insert function key to always be an = sign LBURDETT Excel Discussion (Misc queries) 7 March 24th 06 11:37 AM
Change INSERT FUNCTION icon left of formula bar to = sign? Jamie Setting up and Configuration of Excel 1 January 19th 06 02:47 PM
Can I change the Insert Function button to an equals sign? Jokeyjojo Excel Discussion (Misc queries) 1 January 17th 05 05:45 PM


All times are GMT +1. The time now is 08:37 PM.

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"