Results 1 to 5 of 5

Code to display text & code in a combo list, but display only code when selected

Threaded View

  1. #1
    Registered User
    Join Date
    04-10-2009
    Location
    Colorado
    MS-Off Ver
    Excel 2016
    Posts
    30

    Code to display text & code in a combo list, but display only code when selected

    Hi,

    I think I'm close to getting this right, but my code still isn't working. Would really appreciate any expert advice to get the macros working with my Antibiotic drop down combo list in the attached Excel file.

    Using AbxCombined Range as my drop down view (antibiotic names spelled out) and AbxAbbv Range as my display (abbreviation of antibotic names) after an option is selected. Where am I off in my formula? When I select an option from the drop down, it displays what you see, not the abbreviated name from the AbxAbbv Range.

    My code is below and workbook is attached.

    Thanks!


    Private Sub Worksheet_Change(ByVal Target As Range)
    On Error GoTo errHandler

    Dim wsLookupTbl As Worksheet
    Set wsLookupTbl = Worksheets("LookupTbl")

    If Target.Cells.Count > 1 Then GoTo exitHandler

    If Target.Column = 36 Then
    If Target.Value = "" Then GoTo exitHandler

    Application.EnableEvents = False

    Target.Value = wsLookupTbl.Range("A1") _
    .Offset(Application. _
    WorksheetFunction _
    .Match(Target.Value, _
    wsLookupTbl.Range("AbxCombined"), 0), 0)

    End If

    exitHandler:
    Application.EnableEvents = True
    Exit Sub

    errHandler:
    If Err.Number = 13 Or Err.Number = 1004 Then
    GoTo exitHandler
    Else
    Resume Next
    End If

    End Sub
    Attached Files Attached Files

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Enhancement in code - Selected cell will display in new sheet
    By ExcelUser2707 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-23-2014, 03:39 AM
  2. code won't display a selected image from a file picker, in a user form Any ideas?
    By jakeembx in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 01-09-2014, 02:47 PM
  3. Using IF code for a combo box to display different cells based on option selected
    By ScottBeatty in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-12-2013, 10:36 AM
  4. How to display selected range of cells in Textbox1 using VBA code
    By sreekanth446 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 11-13-2012, 11:40 PM
  5. Looking to code combo/drop down list user selection and display formula results
    By toddbailey in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-07-2012, 06:17 PM
  6. [SOLVED] Use VBA code to display message if combobox selection not in list
    By hurlbut777 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-29-2005, 07:40 PM
  7. [SOLVED] How can I make Excel display HTML code as text
    By roopytoopdongle in forum Excel General
    Replies: 1
    Last Post: 03-20-2005, 03:07 AM

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