PC Review


Reply
 
 
kirkm
Guest
Posts: n/a
 
      21st Mar 2008
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
 
Reply With Quote
 
 
 
 
JLGWhiz
Guest
Posts: n/a
 
      21st Mar 2008
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
>

 
Reply With Quote
 
OssieMac
Guest
Posts: n/a
 
      21st Mar 2008
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
>

 
Reply With Quote
 
OssieMac
Guest
Posts: n/a
 
      21st Mar 2008
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
>

 
Reply With Quote
 
JLGWhiz
Guest
Posts: n/a
 
      21st Mar 2008
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
> >

 
Reply With Quote
 
kirkm
Guest
Posts: n/a
 
      21st Mar 2008


Thank you both very much, it worked perfectly
Cheers - Kirk
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
is there an auto punctuation insert like the auto spell determined09 Microsoft Word Document Management 1 21st Sep 2009 08:17 PM
Need VBA script to auto-insert value upon row insert Phil Microsoft Excel Worksheet Functions 4 6th May 2008 02:41 PM
Can I auto insert a worksheet when I insert a value in a cell. =?Utf-8?B?aWFpbmM=?= Microsoft Excel Worksheet Functions 0 27th Apr 2006 08:37 AM
When I try to insert a header I can't click on 'insert auto text' =?Utf-8?B?TWVs?= Microsoft Access 1 6th May 2005 08:56 AM
Insert cell/format/text/fontsize and auto insert into header? =?Utf-8?B?VW5mdXJsdGhlZmxhZw==?= Microsoft Excel Programming 2 3rd Nov 2004 05:39 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:39 PM.