+ Reply to Thread
Results 1 to 1 of 1

Automatically reflect List changes in data validation cells

  1. #1
    Registered User
    Join Date
    03-29-2013
    Location
    Michigan
    MS-Off Ver
    Excel 2007
    Posts
    5

    Automatically reflect List changes in data validation cells

    I was able to use the VBA code (see below) posted by JBeaucaire to automatically update changes to cells referencing a list when the list was modified.

    The code worked perfectly. The issue is reopening the spreadsheet and adding new cells that refer to my list. The code no longer automatically runs the macro to index the cell. I have tried deleting the code and adding it back but other than manually typing/copying the formula in the cell it isn't working anymore.

    I am new to VBA in excel so I am not sure if this is expected behavior or if there is something else I need to do.

    Thanks in advance for your help

    -----------------------------------------

    Option Explicit

    Private Sub Worksheet_Change(ByVal Target As Range)
    'Summary: Make choices from DV drop downs into formulas, so any changes
    ' in the source lists will flow out to the already filled in cells
    Dim strValidationList As String
    Dim strVal As String
    Dim lngNum As Long

    On Error GoTo Nevermind
    strValidationList = Mid(Target.Validation.Formula1, 2)
    strVal = Target.Value
    lngNum = Application.WorksheetFunction.Match(strVal, Range(strValidationList), 0)

    If strVal <> "" And lngNum > 0 Then
    Application.EnableEvents = False
    Target.Formula = "=INDEX(" & strValidationList & ", " & lngNum & ")"
    End If

    Nevermind:
    Application.EnableEvents = True

    End Sub
    Last edited by cfeist; 04-16-2013 at 08:56 AM. Reason: posted incorrect vba

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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