Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Run macro when adding a new line

Is there any way to intercept the built-in order for new line and run a macro
whenever it is executed?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Run macro when adding a new line

Thank you. This does more or less work, but,

Is there any way
a) to avoid inserting code in the worksheet [in case I need to add another
sheet I would need to add as well the code]
b) to run the macro not at the action following the insertion but just after
the insertion occurs
?


"Gary''s Student" wrote:

To trap inserting a row or adding a row to the bottom of a worksheet, in a
standard module insert:

Public linez As Long
Sub init()
linez = 1
End Sub

and then run init

In Wroksheet code insert:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim nLastRow As Long, r As Range
Set r = ActiveSheet.UsedRange
nLastRow = r.Rows.Count + r.Row - 1
If nLastRow = linez Then
Else
MsgBox ("got bigger")
linez = nLastRow
End If
End Sub

The first time any cell is select, the trap snaps. From then on the trap
will sanp whenever row are added.
--
Gary's Student


"S. G." wrote:

Is there any way to intercept the built-in order for new line and run a macro
whenever it is executed?

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
Problem adding vertical marker line to line chart lbb Charts and Charting in Excel 6 January 9th 09 09:02 AM
macro from columns to rows but adding every time a new line [email protected] Excel Discussion (Misc queries) 2 December 7th 08 08:59 PM
Adding a line to the line/column chart? Steven Charts and Charting in Excel 2 February 12th 07 09:46 PM
Chart Type - Line Column adding a 2nd line [email protected] Charts and Charting in Excel 1 October 24th 06 04:17 PM
adding a line at the end of a macro to name the cell yippy Excel Programming 2 January 3rd 04 02:15 AM


All times are GMT +1. The time now is 12:49 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"