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,616
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,616
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,616
Office Version
365
Platform
Windows
thanks for the feedback
(y)
 

Forum statistics

Threads
1,081,470
Messages
5,358,874
Members
400,514
Latest member
JoHio2577

Some videos you may like

This Week's Hot Topics

  • VBA (Userform)
    Hi All, I just would like to know why my code isn't working. Here is my VBA code: [CODE=vba]Private Sub OKButton_Click() Dim i As Integer...
  • List box that changes fill color
    Hello, I have gone through so many pages trying to figure this out. I have a 2020 calendar that depending on the day needs to have a certain...
  • Remove duplicates and retain one. Cross-linked cases
    Hi all I ran out of google keywords to use and still couldn't find a reference how to achieve the results of a single count. It would be great if...
  • VBA Copy and Paste With Duplicates
    Hello All, I'm in need of some input. My VBA skills are sub-par at best. I've assembled this code from basic research and it works but is...
  • Macro
    is it possible for a macro to run if the active cell value is different to the value above it
  • IF DATE and TIME
    I currently use this to check if date has passed but i also need to set a time on it too. Is it possible? [CODE=vba]=IF(B:B>TODAY(),"Not...
Top