Delete value of range of row double clicked and range of next row

hajiali

Well-known Member
Joined
Sep 8, 2018
Messages
624
Office Version
  1. 2016
Platform
  1. Windows
VBA Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
  Dim resp As VbMsgBoxResult
 
  If Not Intersect(Target, Columns("B")) Is Nothing Then
    Cancel = True
    resp = MsgBox(Prompt:="THIS WILL REMOVE EMPLOYEE FROM THE ROSTER. DO YOU WISH TO CONTINUE?", Buttons:=vbYesNoCancel)
    If resp = vbYes Then
      Range(Replace("B#:D#,F#,H#:EB#", "#", Target.Row)).ClearContents
       ActiveWorkbook.Worksheets("DATS").AutoFilter.Sort.SortFields.Clear
       ActiveWorkbook.Worksheets("DATS").AutoFilter.Sort.SortFields.Add Key _
        :=Range("A1:A1000"), SortOn:=xlSortOnValues, Order:=xlAscending, _
        DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("DATS").AutoFilter.Sort
        .Header = xlYes
        .MatchCase = False
        .Orientation = xlTopToBottom
        .SortMethod = xlPinYin
        .Apply
End With
End If
End If
End Sub

I use the above code when double clicking it deletes the value of the range of that row. I want to be able to add to the range the row after the double click on from AG-EB.

ex: if i double click B3 the values in range B3-D3, F3, H3-EB3, AG4-EB4 will clear contents. adding the range in Green
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
Add this line
VBA Code:
Intersect(Target.Offset(1).EntireRow, Range("AG:EB")).ClearContents
 
Upvote 0
You're welcome & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,214,985
Messages
6,122,606
Members
449,089
Latest member
Motoracer88

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