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

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney

Watch MrExcel Video

Forum statistics

Threads
1,129,682
Messages
5,637,764
Members
416,982
Latest member
lisam77

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