Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / March 2008

Tip: Looking for answers? Try searching our database.

Auto-Insert

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
kirkm - 21 Mar 2008 01:00 GMT
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
JLGWhiz - 21 Mar 2008 01:40 GMT
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.

> 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
OssieMac - 21 Mar 2008 01:41 GMT
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

Signature

Regards,

OssieMac

> 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
JLGWhiz - 21 Mar 2008 02:03 GMT
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.

> One of the following will do it. Note that it inserts a row under the row
> that is double clicked.
[quoted text clipped - 26 lines]
> >
> > Thanks - Kirk
OssieMac - 21 Mar 2008 01:44 GMT
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)
Signature

Regards,

OssieMac

> 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
kirkm - 21 Mar 2008 03:45 GMT
Thank you both very much, it worked perfectly :)
Cheers - Kirk
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.