PDA

View Full Version : [SOLVED:] Doubleclick add row



timmsteven
10-30-2018, 08:30 AM
Hi All

I'm not sure whether I'm doing this right but I'm after a bit of help

I've come across a bit of code (pasted below) that works perfect when pasted into Sheet1 on each excel file. I wanted to be able to use this code on ever workbook I use so I tried pasting it into a blank module in the personal.xlsb workbook but when I try double clicking on cell nothing happens, I'm hoping someone can point out where I'm going wrong

Many Thanks


Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
Cancel = True 'Eliminate Edit status due to doubleclick
Target.Offset(1).EntireRow.Insert
Target.EntireRow.Copy Target.Offset(1).EntireRow
On Error Resume Next
Target.Offset(1).EntireRow.SpecialCells(xlConstants).ClearContents
On Error GoTo 0
End Sub

Fluff
10-30-2018, 08:56 AM
Try putting this in the ThisWorkbook module of your Personal.xlsb
Option Explicit
Public WithEvents App As Application

Private Sub App_SheetBeforeDoubleClick(ByVal Sh As Object, ByVal Target As Range, Cancel As Boolean)
Cancel = True 'Eliminate Edit status due to doubleclick
Target.Offset(1).EntireRow.Insert
Target.EntireRow.Copy Target.Offset(1).EntireRow
On Error Resume Next
Target.Offset(1).EntireRow.SpecialCells(xlConstants).ClearContents
On Error GoTo 0

End Sub

Private Sub Workbook_Open()
Set App = Application
End Sub

timmsteven
10-30-2018, 09:05 AM
Thank ever so much this is absolutely perfect and works flawlessly.

Fluff
10-31-2018, 01:04 PM
Glad to help & thanks for the feedback