+ Reply to Thread
Results 1 to 3 of 3

Auto populate dependent validation list with fist values from list

  1. #1
    Registered User
    Join Date
    08-26-2022
    Location
    Mpls, MN
    MS-Off Ver
    10
    Posts
    1

    Question Auto populate dependent validation list with fist values from list

    I'm working on a ROI spreadsheet and want to select from a 'independent Category list' and have the solved values in the 'dependent Values lists' enter the cells automatically.

    I found this code that I put into the VBA:
    Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Address = "$G$4" Then
    Range("H4:I7").Value = "Select"
    End If
    End Sub
    That will set all validation boxes H4:I7 to "Select" after choosing the Category, but I want each cell to update with the value rather than having to keep selecting them since it's the only value in the list.

    I then found this VBA that will reset as I need, but have no idea how to make it work at all...
    Sub ResetDropDowns()

    Dim rngLists As Range
    Dim ListCell As Range

    On Error Resume Next
    Set rngLists = Sheets("Entry Sheet").UsedRange.SpecialCells(xlCellTypeAllValidation)
    On Error GoTo 0

    If Not rngLists Is Nothing Then
    For Each ListCell In rngLists.Cells
    ListCell.Value = Range(Trim(Mid(Replace(ListCell.Validation.Formula1, ":", String(99, " ")), 2, 99))).Value
    Next ListCell
    End If

    End Sub
    Also, After the independent Category is chosen, I will need to enter values into the white boxes under Product 1 and 2. These boxes move around depending on what ROI category is selected: Current = No white; Adj/ Price =- List & Costs, NPI = List & GM. So, I'm hoping I can just reassign the code to accomplish calling the 'dependent recalculated Values' to the correct cells as changes are made.

    Here's a pic of the spread sheet, and this is the dependent list code that I put into the Validation Source (the result numbers in the image) for Product 1 List Price: =INDEX($E$43:$G$43,,MATCH($G$4,$E$42:$G$42,0))

    Thanks all for the help.

    Independent Validation List: E42:G42 -> G4
    Dependent Validation List: E43:G46 -> H4:H7

    2022-08-26_13-50-36.png
    Attached Images Attached Images

  2. #2
    Forum Expert torachan's Avatar
    Join Date
    12-27-2012
    Location
    market harborough, england
    MS-Off Ver
    Excel 2010
    Posts
    4,303

    Re: Auto populate dependent validation list with fist values from list

    a workbook is worth a thousand pictures - see big yellow banner how to upload.
    Torachan,

    Mission statement; Promote the use of Tables, Outlaw the use of 'merged cells' and 'RowSource'.

  3. #3
    Registered User
    Join Date
    11-16-2019
    Location
    North Carolina
    MS-Off Ver
    2018
    Posts
    1

    Thumbs up Re: Auto populate dependent validation list with fist values from list

    This solves it. Right click the tab to open the Code editor. Copy and past below to the window. Change Sheet1 and the Cells to what ever you need. Create a Macro button using an inserted Icon and right click it and select make macro.

    Sub ResetDropDowns()

    Dim rngLists As Range
    Dim ListCell As Range

    On Error Resume Next
    Set rngLists = Sheets("Sheet1").Range("G21,H21")
    On Error GoTo 0

    If Not rngLists Is Nothing Then
    For Each ListCell In rngLists.Cells
    ListCell.Value = Range(Trim(Mid(Replace(ListCell.Validation.Formula1, ":", String(99, " ")), 2, 99))).Value
    Next ListCell
    End If

    End Sub

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 10
    Last Post: 02-15-2021, 01:55 AM
  2. [SOLVED] auto populate values by choosing the combo list
    By nawas in forum Excel General
    Replies: 3
    Last Post: 08-19-2018, 07:15 AM
  3. Auto Populate Dynamic List Using Data Validation Drop Down
    By HaleServices in forum Excel General
    Replies: 1
    Last Post: 08-17-2017, 08:51 PM
  4. [SOLVED] How to auto populate other cells when selecting values in Excel drop down list?
    By lougs7 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 10-24-2016, 08:52 AM
  5. Replies: 1
    Last Post: 11-05-2013, 12:40 AM
  6. Replies: 3
    Last Post: 02-28-2012, 11:54 AM
  7. Dependent Validation List - Auto Populate
    By himey77 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-25-2011, 11:07 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