Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Problem adding vertical marker line to line chart | Charts and Charting in Excel | |||
macro from columns to rows but adding every time a new line | Excel Discussion (Misc queries) | |||
Adding a line to the line/column chart? | Charts and Charting in Excel | |||
Chart Type - Line Column adding a 2nd line | Charts and Charting in Excel | |||
adding a line at the end of a macro to name the cell | Excel Programming |