Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 25
Default To duplicate a row

The indicated part of the following code needs to be modified in such a
way that the row of the double clicked cell is duplicated for editing.
There are no formulae involved. The new row is to be inserted directly
below the active cell.

Private Sub Worksheet_BeforeDoubleClick _
(ByVal Target As Range, Cancel As Boolean)
On Error GoTo err_handler
With Target
If Not Intersect(Target, Range("N2:N6")) Is Nothing Then
If Not IsEmpty(.Value) Then
ThisWorkbook.FollowHyperlink ThisWorkbook.Path _
& "\" & .Value
End If
End If
'------------------ This is the code of interest ------------------
If .Row 8 Then
Range(Cells(ActiveCell.Row, "A"), _
Cells(ActiveCell.Row, "Z")).Insert xlDown
Range("B" & ActiveCell.Row).Select
On Error GoTo 0
End If
'-----------------------------------------------------------------------------
End With
Exit Sub

err_handler:
MsgBox "An error has been made" & vbCrLf _
& "File name not recognised.", _
vbExclamation, "Error Notice"
End Sub


All suggestions gratefully received.

Geoff

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 414
Default To duplicate a row

Try:

Private Sub Worksheet_BeforeDoubleClick _
(ByVal Target As Range, Cancel As Boolean)
On Error GoTo err_handler
With Target
If Not Intersect(Target, Range("N2:N6")) Is Nothing Then
If Not IsEmpty(.Value) Then
ThisWorkbook.FollowHyperlink ThisWorkbook.Path _
& "\" & .Value
End If
End If

If .Row 8 Then
Rows(.Row).Copy
Cells(.Row + 1, 1).Insert shift:=xlDown
Application.CutCopyMode = False
Cancel = True
End If

End With
Exit Sub

err_handler:
MsgBox "An error has been made" & vbCrLf _
& "File name not recognised.", _
vbExclamation, "Error Notice"
End Sub

Hope this helps
Rowan

wrote:
The indicated part of the following code needs to be modified in such a
way that the row of the double clicked cell is duplicated for editing.
There are no formulae involved. The new row is to be inserted directly
below the active cell.

Private Sub Worksheet_BeforeDoubleClick _
(ByVal Target As Range, Cancel As Boolean)
On Error GoTo err_handler
With Target
If Not Intersect(Target, Range("N2:N6")) Is Nothing Then
If Not IsEmpty(.Value) Then
ThisWorkbook.FollowHyperlink ThisWorkbook.Path _
& "\" & .Value
End If
End If
'------------------ This is the code of interest ------------------
If .Row 8 Then
Range(Cells(ActiveCell.Row, "A"), _
Cells(ActiveCell.Row, "Z")).Insert xlDown
Range("B" & ActiveCell.Row).Select
On Error GoTo 0
End If
'-----------------------------------------------------------------------------
End With
Exit Sub

err_handler:
MsgBox "An error has been made" & vbCrLf _
& "File name not recognised.", _
vbExclamation, "Error Notice"
End Sub


All suggestions gratefully received.

Geoff

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 25
Default To duplicate a row

Thank you Rowan.... That works a treat....

Geoff

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 414
Default To duplicate a row

You're welcome.

wrote:
Thank you Rowan.... That works a treat....

Geoff

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default To duplicate a row

If .Row 8 Then
Cells(.Row,1).Resize(1,26).Offset(1,0).Insert Shift:=xlDown
Cells(.Row,1).Resize(1,26).Offset(1,0).Filldown
On Error GoTo 0
End If

--
Regards,
Tom Ogilvy


wrote in message
oups.com...
The indicated part of the following code needs to be modified in such a
way that the row of the double clicked cell is duplicated for editing.
There are no formulae involved. The new row is to be inserted directly
below the active cell.

Private Sub Worksheet_BeforeDoubleClick _
(ByVal Target As Range, Cancel As Boolean)
On Error GoTo err_handler
With Target
If Not Intersect(Target, Range("N2:N6")) Is Nothing Then
If Not IsEmpty(.Value) Then
ThisWorkbook.FollowHyperlink ThisWorkbook.Path _
& "\" & .Value
End If
End If
'------------------ This is the code of interest ------------------
If .Row 8 Then
Range(Cells(ActiveCell.Row, "A"), _
Cells(ActiveCell.Row, "Z")).Insert xlDown
Range("B" & ActiveCell.Row).Select
On Error GoTo 0
End If

'---------------------------------------------------------------------------
--
End With
Exit Sub

err_handler:
MsgBox "An error has been made" & vbCrLf _
& "File name not recognised.", _
vbExclamation, "Error Notice"
End Sub


All suggestions gratefully received.

Geoff





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 25
Default To duplicate a row

And Thank you Tom too.

That works a treat as well.

Geoff

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
duplicate Matt Excel Discussion (Misc queries) 1 September 23rd 09 11:30 PM
Duplicate purplerose Excel Worksheet Functions 2 October 18th 08 12:31 AM
How do you delete duplicate addresses, but keep duplicate names? Shelly Excel Discussion (Misc queries) 1 August 28th 06 10:36 PM
duplicate Metalteck Excel Discussion (Misc queries) 2 May 11th 05 10:04 PM
Duplicate Bottle Excel Worksheet Functions 3 April 14th 05 04:57 PM


All times are GMT +1. The time now is 12:02 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"