#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 91
Default Auto-Insert

Could anyone help with some VB code to do the following,

After double clicking a cell in say Row 17, a new row 18 is inserted.

Thanks - Kirk
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default Auto-Insert

I think you would have to use a control object of some type, where you would
select the row for the insert to execute on and then click the control which
would initiate the insertion based on the selection. To use double click on
a point on the worksheet would require deactivating the current double click
event which allows edit access to the active cell.

"kirkm" wrote:

Could anyone help with some VB code to do the following,

After double clicking a cell in say Row 17, a new row 18 is inserted.

Thanks - Kirk

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,510
Default Auto-Insert

One of the following will do it. Note that it inserts a row under the row
that is double clicked.

Private Sub Worksheet_BeforeDoubleClick _
(ByVal Target As Range, Cancel As Boolean)

Cancel = True 'Cancel Edit mode started by double click

ActiveCell.Offset(1, 0).EntireRow.Insert Shift:=xlDown

End Sub

The following is similar but will only run if you double click column A.

Private Sub Worksheet_BeforeDoubleClick _
(ByVal Target As Range, Cancel As Boolean)

Cancel = True 'Cancel Edit mode started by double click

If Target.Column = 1 Then
ActiveCell.Offset(1, 0).EntireRow.Insert Shift:=xlDown
End If

End Sub


--
Regards,

OssieMac


"kirkm" wrote:

Could anyone help with some VB code to do the following,

After double clicking a cell in say Row 17, a new row 18 is inserted.

Thanks - Kirk

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,510
Default Auto-Insert

Forgot to say right click on the worksheet name tab and select View Code and
insert one of the macros into the editor and then close the editor (X in red
background top right of screen)
--
Regards,

OssieMac


"kirkm" wrote:

Could anyone help with some VB code to do the following,

After double clicking a cell in say Row 17, a new row 18 is inserted.

Thanks - Kirk

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default Auto-Insert

Well, shut my mouth! This old dog just learned a new trick. I never thought
about just stepping past the cell edit. Way to go Ossie.

"OssieMac" wrote:

One of the following will do it. Note that it inserts a row under the row
that is double clicked.

Private Sub Worksheet_BeforeDoubleClick _
(ByVal Target As Range, Cancel As Boolean)

Cancel = True 'Cancel Edit mode started by double click

ActiveCell.Offset(1, 0).EntireRow.Insert Shift:=xlDown

End Sub

The following is similar but will only run if you double click column A.

Private Sub Worksheet_BeforeDoubleClick _
(ByVal Target As Range, Cancel As Boolean)

Cancel = True 'Cancel Edit mode started by double click

If Target.Column = 1 Then
ActiveCell.Offset(1, 0).EntireRow.Insert Shift:=xlDown
End If

End Sub


--
Regards,

OssieMac


"kirkm" wrote:

Could anyone help with some VB code to do the following,

After double clicking a cell in say Row 17, a new row 18 is inserted.

Thanks - Kirk



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 91
Default Auto-Insert



Thank you both very much, it worked perfectly :)
Cheers - Kirk
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
Need VBA script to auto-insert value upon row insert Phil Excel Worksheet Functions 4 May 6th 08 02:41 PM
Auto insert row: George Excel Worksheet Functions 1 November 6th 07 04:21 PM
Can I auto insert a worksheet when I insert a value in a cell. iainc Excel Worksheet Functions 0 April 27th 06 08:37 AM
Auto Insert/Auto Formula? Abacus Excel Worksheet Functions 1 February 3rd 06 11:33 AM
Insert cell/format/text/fontsize and auto insert into header? Unfurltheflag Excel Programming 2 November 3rd 04 05:39 PM


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