clearing merged cells by offset

Klister

Board Regular
Joined
Dec 11, 2015
Messages
60
I have three dropdown lists. The second and third list are dependent on whatever is selected in the first list.
First list is in range W2:X2 (merged)
Second list is in range Y2:Z2 (merged)
Third list is in range AA2:AC2 (merged)
these cells are merged for readability because cells in lower rows are less wide
now I have below code to clear the contents of list 2 and 3 when the first list selection is changed. Unfortunately it is not clearing, probably because I'm using merged cells. I already tried to use range(W2:Y2").offset(,2).clearcontents but this doesn't work either. Can anyone tell me what I'm doing wrong?

Code:
Private Sub Worksheet_Change(ByVal Target As Range)


    If Target.Address = "$W$2" Then
        If Target.Validation.Type = 3 Then
            Application.EnableEvents = False
            Target.Offset(, 2).ClearContents
            Target.Offset(, 3).ClearContents
    
        End If
    
exitHandler:
        Application.EnableEvents = True
        Exit Sub
    End If
End Sub
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,164,565
Messages
5,838,135
Members
430,530
Latest member
sonofagunn123

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
Top