![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
New Member
Join Date: Feb 2002
Posts: 16
|
How do I write a macro to insert a line at a change in value of one column?
|
|
|
|
|
|
#2 | |
|
MrExcel MVP
Join Date: Feb 2002
Location: Auckland, New Zealand
Posts: 4,209
|
Quote:
Use the worksheet change event Enter code in the sheets code page Ie. Right click sheet tab select view code paste this code; Private Sub Worksheet_Change(ByVal Target As Range) 'Assumes column to test is 1 If Target.Column = 1 Then 'Insert cell Target.Offset(1, 0).Insert Shift:=xlDown 'Insert Row 'Target.Offset(1, 0).EntireRow.Insert End If End Sub Not sure if you wanted to insert ENTIRE row or just a cell gave both options. HTH Ivan |
|
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|