Update a Named Range from a Drop Down Box

tigerdel

New Member
Joined
Oct 13, 2015
Messages
40
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,288
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
40
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,288
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:

Forum statistics

Threads
1,078,447
Messages
5,340,344
Members
399,370
Latest member
salamon

Some videos you may like

This Week's Hot Topics

  • Problem with Radio Button's format control
    I am creating an employee evaluation template (a sample is below) Column A is the category Column B, C D, E and F will be ratings (unacceptable...
  • Last Display on userform to a Listbox
    [CODE=vba] lstdisplay.ColumnCount = 15 lstdisplay.RowSource = "A1:O600000" [/CODE] So when i do this it Displays everything on the sheet i am...
  • Rename and move files to a new location
    Dear all, I have an excel file with the following information. The actual file name is at column A but i want to rename it using the following...
  • Help with True/False Formula
    Hello! Am stumped how to fix this formula, in which my result returns 'True', but it should return False. =IF(AG2=True...
  • Clear extra characters from a provided range of cells
    Dear All, I have following code which gives me desired output to remove extra characters from a provided range. But it takes too much time when...
  • Help with Current and highest streaks
    Hi there, I've just joined the forum and this is my first post. I've already spent quite a bit of time searching the net and this forum for a...
Top