+ Reply to Thread
Results 1 to 5 of 5

same column response

  1. #1
    Registered User
    Join Date
    04-04-2010
    Location
    london
    MS-Off Ver
    Latest for the mac
    Posts
    20

    same column response

    Hi Guys/Gals

    Is it possible in ONE column to do this.

    say for example the cell in question is Q10.

    I want to create a drop down box that has a list of locations. now in a table array these locations although they have a name, they also have a numeric code.

    I want to be able to drop down a box, select a location by name, but it return in the same cell the numeric code number instead.

    Is this possible??


    Regards


    Steve
    Last edited by shutchinson; 04-21-2011 at 06:17 PM.

  2. #2
    Forum Expert tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: same column response

    Steve,

    In order to do what you're looking for you would first create a regular validation list (my sample workbook put it in Q10) and then use the Worksheet_Change event. Here's the code:

    Please Login or Register  to view this content.


    Notes:
    -This sample code only checks for changes in Q10
    -This sample code assumes the table is in range A2:B4 of the same sheet

    I have attached a sample workbook so you can see what it looks like.

    Hope that helps,
    ~tigeravatar
    Attached Files Attached Files
    Last edited by tigeravatar; 04-21-2011 at 06:49 PM. Reason: clarity

  3. #3
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,491

    Re: same column response

    @tigeravatar: Neat routine

    As you are making a cell change on a sheet that is monitored by a worksheet change event, I think you need to add an EnableEvents = False/True

    Please Login or Register  to view this content.


    If you track the code, you'll find it goes through the routine twice (unless you disable events first)

    Regards
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  4. #4
    Forum Expert tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: same column response

    @TMShucks,

    Thanks! I hadn't even thought about that

    ~tigeravatar

  5. #5
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: same column response

    FWIW you can do this without VBA.

    How viable the non-VBA approach is rather depends on number of items and any additional requirements (referencing etc...)

    For sake of ex. we create the 4 items in A1:A4

    A1: 123
    A2: 345
    A3: 456
    A4: 789

    Highlight A1 and set Custom Format to: "Place A"
    Repeat for A2:A4 using a different "location name" for each.

    To B1 we apply a List Validation with A1:A4 as source.

    You will find the list appears in B1 using the A1:A4 Custom Format values (ie strings) but when selected returns the underlying numeric value.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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