+ Reply to Thread
Results 1 to 2 of 2

Data validation list - automatically update cells where used

Hybrid View

  1. #1
    Registered User
    Join Date
    01-24-2014
    Location
    Houston, TX
    MS-Off Ver
    Excel 2003
    Posts
    2

    Data validation list - automatically update cells where used

    I used the exact code mentioned in comment #1 above this thread, but it won't run. I had it working once, then made too many changes so I deleted everything and started from scratch. It's under the Worksheet as instructed. Here is my worksheet: Book1.xlsm

    What am I missing?

    Raegan
    Last edited by JBeaucaire; 01-26-2014 at 04:51 PM.

  2. #2
    Forum Contributor
    Join Date
    04-25-2013
    Location
    Stockholm, Sweden
    MS-Off Ver
    Excel 2010
    Posts
    150

    Re: Data validation list - automatically update cells where used

    Hi,

    I think I've managed to figure out a solution. I'm sure that it's not the cleanest way of solving it, but it seems to work nevertheless:

    Option Explicit
    
    Private oldValue As String
    Private Const DVCell As String = "A1"
    Private dataList As String
    Private lrow As Long
    
    Private Sub Worksheet_Change(ByVal Target As Range)
    
    Dim cell As Range
    lrow = Cells(Rows.Count, "b").End(xlUp).Row
    dataList = "b1:b" & lrow
    
    On Error GoTo ws_exit:
    Application.EnableEvents = False
    If Target.Count = 1 Then
    If Not Intersect(Target, Range(dataList)) Is Nothing Then
    With Target
    If Range(DVCell).Value = oldValue Then
    Range(DVCell).Value = .Value
    End If
    End With
    End If
    End If
    
        ActiveWorkbook.Names.Add Name:="list", RefersToR1C1:="=Sheet1!R1C2:R" & Cells(Rows.Count, "b").End(xlUp).Row & "C2"
        Range("A1").Select
        With Selection.Validation
            .Delete
            .Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
            xlBetween, Formula1:="=list"
            .IgnoreBlank = True
            .InCellDropdown = True
            .InputTitle = ""
            .ErrorTitle = ""
            .InputMessage = ""
            .ErrorMessage = ""
            .ShowInput = True
            .ShowError = True
        End With
    
        For Each cell In Range(dataList)
            If cell.Value = Range(DVCell).Value Then
                GoTo ws_exit
            Else
            End If
        Next cell
        
        Range(DVCell) = Range("b" & lrow).Value
    
    ws_exit:
    Application.EnableEvents = True
    End Sub
    
    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    
    lrow = Cells(Rows.Count, "b").End(xlUp).Row
    dataList = "b1:b" & lrow
    
    If Target.Count = 1 Then
    If Not Intersect(Target, Range(dataList)) Is Nothing Then
    If Not IsEmpty(Target) Then
    oldValue = Target.Value
    End If
    End If
    End If
    End Sub

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Data validation list - automatically update cells where used
    By kmroy0320 in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 02-18-2022, 07:15 AM
  2. Replies: 4
    Last Post: 07-03-2014, 02:37 AM
  3. multiple data validation list want to update automatically excel 2010
    By ninny76 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-14-2013, 11:57 PM
  4. Automatically reflect List changes in data validation cells
    By cfeist in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-16-2013, 08:52 AM
  5. Replies: 1
    Last Post: 04-19-2011, 08:42 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1