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,238
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,238
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,077,678
Messages
5,335,621
Members
399,029
Latest member
JSO

Some videos you may like

This Week's Hot Topics

Top