Update a Named Range from a Drop Down Box

tigerdel

New Member
Joined
Oct 13, 2015
Messages
44
I have a sheet that contains a Data Validated drop down.

There will be occasions where the drop down does not contain the required value.

So, I want to give the user the ability to type the required value into the drop down and it will then add it to the named range.

I have already set up a dynamic Range [called Supplier]

Is this possible??

Thanks

Derek
 

Yongle

Well-known Member
Joined
Mar 11, 2015
Messages
4,645
Office Version
365
Platform
Windows
Yes it is possible
- what is the RefersTo formula of named range Supplier?
- requires a few lines of very basic VBA
 
Last edited:

tigerdel

New Member
Joined
Oct 13, 2015
Messages
44
Yes it is possible
- what is the RefersTo formula of named range Supplier?
- requires a few lines of very basic VBA
Each cell in column D is linked to a dynamic range called Supplier

The formula in the Named Range is:

=OFFSET(Lists!$A$1,0,0,COUNTA(Lists!$A:$A),1)
 
Last edited:

Yongle

Well-known Member
Joined
Mar 11, 2015
Messages
4,645
Office Version
365
Platform
Windows
Standard DV message is replaced with VBA message when unauthorised value is entered
- click OK to add value to named range
- click Cancel to abort

Test on a COPY of your workbook

1. Amend Data Validation in any cell in column D EXCEPT D1 (assumed header)
- on Settings tab, check the box to "Apply these settings to all other cells with the same settings"
- on Error Alert tab, uncheck the box "Show Error Alert after invalid data is entered"
(allows user to enter any value)

2. Add code as instructed belowCode goes in sheet module of the sheet containing Data Validation
right-click on sheet tab\ select View Code \ Paste code below into code window \ {ALT}{F11} to go back to Excel
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Row < 2 Then Exit Sub
    If Not Intersect(Target, Range("D:D")) Is Nothing Then
        If WorksheetFunction.CountIf([Supplier], Target) = 0 Then
           If MsgBox(Target & vbCr & ".......... will be added to named range", vbOKCancel) = vbOK Then
                [Supplier].Offset([Supplier].Rows.Count).Resize(1) = Target
            End If
        End If
    End If
End Sub
3. Test
 
Last edited:

Yongle

Well-known Member
Joined
Mar 11, 2015
Messages
4,645
Office Version
365
Platform
Windows
thanks for the feedback
(y)
 

Forum statistics

Threads
1,081,753
Messages
5,361,097
Members
400,613
Latest member
Markdc123

Some videos you may like

This Week's Hot Topics

  • populate from drop list with multiple tables
    Hi All, i have a drop list that displays data, what i want is when i select one of those from the list to populate text from different tables on...
  • Find list of words from sheet2 in sheet1 before a comma and extract text vba
    Hi Friends, Trying to find the solution on my task. But did not find suitable one to the need. Here is my query and sample file with details...
  • Dynamic Formula entry - VBA code sought
    Hello, really hope one of you experts can help with this - i've spent hours on this and getting no-where. .I have a set of data (more rows than...
  • Listbox Header
    Have a named range called "AccidentsHeader" Within my code I have: [CODE]Private Sub CommandButton1_Click() ListBox1.RowSource =...
  • Complex Heat Map using conditional formatting
    Good day excel world. I have a concern. Below link have a list of countries that carries each country unique data. [URL...
  • Conditional formatting
    Hi good morning, hope you can help me please, I have cells P4:P54 and if this cell is equal to 1 then i want row O to say "Fully Utilised" and to...
Top