Consulting

Results 1 to 4 of 4

Thread: Doubleclick add row

  1. #1

    Doubleclick add row

    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
    Last edited by Aussiebear; 11-01-2018 at 01:45 AM. Reason: Added tags to wrap code

  2. #2
    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

  3. #3
    Thank ever so much this is absolutely perfect and works flawlessly.

  4. #4
    Glad to help & thanks for the feedback

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •