Results 1 to 5 of 5

Thread: delete data rage on double clicking cell
Thanks Thanks: 0 Likes Likes: 0

  1. #1
    Board Regular redspanna's Avatar
    Join Date
    Jul 2005
    Location
    London
    Posts
    1,426
    Post Thanks / Like
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Default delete data rage on double clicking cell

    Hello all

    I have a long list of date that populates columns A:F

    Can I have help with code that will simply delete the data held on that particular row through columns A:F

    For example if cell A16 is double clicked then A16:F16 id deleted and the remaining rows beneath are all moved up to fill in the gap.

    Thanks in advance

  2. #2
    Board Regular James006's Avatar
    Join Date
    Apr 2009
    Posts
    3,355
    Post Thanks / Like
    Mentioned
    19 Post(s)
    Tagged
    1 Thread(s)

    Default Re: delete data rage on double clicking cell

    Hello,

    You can test following event macro

    Code:
    Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
        Rows(Target.Row & ":" & Target.Row).Delete Shift:=xlUp
        Cancel = True
    End Sub
    Hope this will help

  3. #3
    MrExcel MVP
    Moderator
    Peter_SSs's Avatar
    Join Date
    May 2005
    Location
    Macksville, Australia
    Posts
    40,969
    Post Thanks / Like
    Mentioned
    90 Post(s)
    Tagged
    21 Thread(s)

    Default Re: delete data rage on double clicking cell

    Quote Originally Posted by redspanna View Post
    For example if cell A16 is double clicked then A16:F16 id deleted and the remaining rows beneath are all moved up to fill in the gap.
    If you only want this to work if a column A cell is double-clicked and you only want 6 columns of the row deleted, then try this
    Code:
    Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
      If Target.Column = 1 Then
        Cancel = True
        Target.Resize(, 6).Delete Shift:=xlUp
      End If
    End Sub
    Last edited by Peter_SSs; Sep 17th, 2019 at 05:34 AM.
    Hope this helps, good luck.
    Peter
    Excel 365 - Windows 10
    - Want to help your helpers by posting a small, copyable, screen shot directly in your post? Look here
    - If posting vba code, please use Code Tags - like this [code]Paste code here[/code] - or use the # key in the Reply window
    - Read: Forum Rules, Forum Use Guidelines, & FAQ

  4. #4
    Board Regular redspanna's Avatar
    Join Date
    Jul 2005
    Location
    London
    Posts
    1,426
    Post Thanks / Like
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Default Re: delete data rage on double clicking cell

    Quote Originally Posted by Peter_SSs View Post
    If you only want this to work if a column A cell is double-clicked and you only want 6 columns of the row deleted, then try this
    Code:
    Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
      If Target.Column = 1 Then
        Cancel = True
        Target.Resize(, 6).Delete Shift:=xlUp
      End If
    End Sub
    Perfect - thanks a lot

  5. #5
    MrExcel MVP
    Moderator
    Peter_SSs's Avatar
    Join Date
    May 2005
    Location
    Macksville, Australia
    Posts
    40,969
    Post Thanks / Like
    Mentioned
    90 Post(s)
    Tagged
    21 Thread(s)

    Default Re: delete data rage on double clicking cell

    Quote Originally Posted by redspanna View Post
    Perfect - thanks a lot
    You're welcome.
    Hope this helps, good luck.
    Peter
    Excel 365 - Windows 10
    - Want to help your helpers by posting a small, copyable, screen shot directly in your post? Look here
    - If posting vba code, please use Code Tags - like this [code]Paste code here[/code] - or use the # key in the Reply window
    - Read: Forum Rules, Forum Use Guidelines, & FAQ

Some videos you may like

User Tag List

Tags for this Thread

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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