delete data rage on double clicking cell

redspanna

Well-known Member
Joined
Jul 27, 2005
Messages
1,604
Office Version
  1. 365
Platform
  1. Windows
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
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
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
 
Upvote 0
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:
Upvote 0
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
 
Upvote 0

Forum statistics

Threads
1,224,739
Messages
6,180,676
Members
452,993
Latest member
FDARYABEE

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top