Results 1 to 9 of 9

VBA Code to clear multiple dependent drop down lists

Threaded View

EmmaRose88 VBA Code to clear multiple... 06-22-2021, 10:18 AM
Richard Buttrey Re: VBA Code to clear... 06-22-2021, 10:55 AM
EmmaRose88 Re: VBA Code to clear... 06-23-2021, 09:27 AM
EmmaRose88 Re: VBA Code to clear... 06-23-2021, 09:38 AM
Richard Buttrey Re: VBA Code to clear... 06-23-2021, 10:15 AM
EmmaRose88 Re: VBA Code to clear... 06-25-2021, 03:50 AM
torachan Re: VBA Code to clear... 06-22-2021, 10:58 AM
torachan Re: VBA Code to clear... 06-23-2021, 09:51 AM
Zaerick Re: VBA Code to clear... 06-23-2021, 10:18 AM
  1. #1
    Registered User
    Join Date
    06-21-2021
    Location
    West Midlands, England
    MS-Off Ver
    2010
    Posts
    4

    VBA Code to clear multiple dependent drop down lists

    Hi!

    A Couple of questions here about VBA codes -

    I have a form with multiple dependent drop down lists & require the cells containing these lists to clear each time the parent drop down is changed.

    I've managed to do this with 2 parent & dependent lists so far using the below code:

    Just to briefly explain;
    B16 is my first parent list with C16:G16 containing dependants which then clear when B16 is changed
    B18 is my 2nd parent list with C18:F18 & B20:G20 containing dependent lists or formulas which then clear when B18 is changed. My formulas have disappeared though so I'm guessing the below code has cleared them out?

    Private Sub Worksheet_Change(ByVal Target As Range)
    On Error Resume Next
    If Target.Column = 2 Then
    If Target.Validation.Type = 3 Then
    Application.EnableEvents = False
    Target.Offset(0, 1).ClearContents
    Target.Offset(0, 2).ClearContents
    Target.Offset(0, 3).ClearContents
    Target.Offset(0, 4).ClearContents
    Target.Offset(0, 5).ClearContents
    Target.Offset(6, 0).ClearContents
    Target.Offset(6, 1).ClearContents
    Target.Offset(6, 2).ClearContents
    Target.Offset(6, 3).ClearContents
    Target.Offset(6, 4).ClearContents
    
    End If
    End If
    
    
    exitHandler:
    Application.EnableEvents = True
    Exit Sub
    End Sub


    Private Sub Change(ByVal Target As Range)
    On Error Resume Next
    If Target.Column = 2 Then
    If Target.Validation.Type = 5 Then
    Application.EnableEvents = False
    Target.Offset(0, 1).ClearContents
    Target.Offset(0, 2).ClearContents
    Target.Offset(0, 3).ClearContents
    Target.Offset(0, 4).ClearContents
    Target.Offset(0, 5).ClearContents
    End If
    End If
    exitHandler:
    Application.EnableEvents = True
    Exit Sub
    End Sub

    I then want my new parent drop down's C27:C42 to clear out D27:E42 - I'm just not sure how to get multiple codes in the sheet.

    It's been a very long time (about 14 years) since I last looked at macro's etc so I'm still quite new to this.

    If anyone could give some advice on the codes above & if I could be doing things a different way it would be much appreciated
    Last edited by Richard Buttrey; 06-23-2021 at 10:13 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Multiple dependent drop down lists
    By Ronald Reagan in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 12-23-2020, 09:10 PM
  2. Replies: 4
    Last Post: 01-27-2020, 09:32 AM
  3. [SOLVED] Clear up to three dependent drop down lists based on selection in superior drop down list
    By theletterh in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 03-04-2016, 09:31 PM
  4. [SOLVED] Help with multiple dependent drop down lists
    By NHamilton07 in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 05-28-2014, 07:58 AM
  5. [SOLVED] The VBA code to auto-clear dependent drop down selection when parent cell change.
    By Hotgirl in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 10-29-2012, 07:48 PM
  6. [SOLVED] Clear Dependent Drop Down Lists
    By Ambassador777 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 02-03-2012, 11:38 PM
  7. [SOLVED] Multiple Dependent Drop Down lists?
    By Steve in forum Excel General
    Replies: 0
    Last Post: 12-07-2005, 04:40 PM

Tags for this Thread

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1