Update a Named Range from a Drop Down Box

tigerdel

Board Regular
Joined
Oct 13, 2015
Messages
145
Office Version
  1. 365
Platform
  1. Windows
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
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
Yes it is possible
- what is the RefersTo formula of named range Supplier?
- requires a few lines of very basic VBA
 
Last edited:
Upvote 0
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:
Upvote 0
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:
Upvote 0

Forum statistics

Threads
1,213,530
Messages
6,114,163
Members
448,554
Latest member
Gleisner2

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top