+ Reply to Thread
Results 1 to 13 of 13

Place text in a specific cell based on two separate drop down list entries

  1. #1
    Registered User
    Join Date
    07-16-2014
    Location
    England
    MS-Off Ver
    2010
    Posts
    25

    Place text in a specific cell based on two separate drop down list entries

    Hi all,

    New to VBA and tried looking in a lot of places so apologies if this has been answered elsewhere.

    I have two drop down lists on a spreadsheet and a button entitled 'enter'. What I want to happen is for when the user clicks 'enter' some text appears in the same row but a few columns right of a row specific to the data in row A.

    So:

    In cell G3 I have a drop down list called 'names' which references cells A3:A32 (a class list). And in cell G4 I have another drop down list which has a range of possible intervention strategies in a short code (eg. DT for BfL). This is stored in a table to aid data validation and there is a last column in the data validation table which is the full term for the intervention short code (eg. "A number of detentions set as a result of poor Behaviour for Learning").

    The data validation table is as follows:
    Intervention_tbl6 - refers to ='Pro Int Template T1!'$H$2:$J$31
    PupilNames_dd - refers to =Intervention_tbl6[Names]
    InterventionShortCode_dd = refers to =Intervention_tbl6[Intervention short code]
    $J$2:$J$31 has the full terms for the intervention short code so if using VLOOKUP for example it would be in the column next to the short code.

    My aim is for a user to select a name in the drop down in G3, select a code in G4, click enter and for the full term to appear in column F in the same row as the name that the user selected. (eg. User selects A.N.Other who appears in row 15, user selects 'DT for BFL' and "A number of detentions set as a result of poor Behaviour for Learning" appears in cell F15 once they have clicked enter.

    Hope that makes some sense! If anyone could point me in the direction of an example of what I'm looking for or has any tips I'd be very grateful!

    Thanks in advance.

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,717

    Re: Place text in a specific cell based on two separate drop down list entries

    This would be a lot easier if we had your file. Can you remove any private data and attach it?
    Jeff
    | | |·| |·| |·| |·| | |:| | |·| |·|
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Registered User
    Join Date
    07-16-2014
    Location
    England
    MS-Off Ver
    2010
    Posts
    25

    Re: Place text in a specific cell based on two separate drop down list entries

    Example Progress Template.xlsm

    Of course! Sorry, should have done that earlier. Now attached.

  4. #4
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,717

    Re: Place text in a specific cell based on two separate drop down list entries

    What do you want to happen if someone enters a second code for the same person?

  5. #5
    Registered User
    Join Date
    07-16-2014
    Location
    England
    MS-Off Ver
    2010
    Posts
    25

    Re: Place text in a specific cell based on two separate drop down list entries

    If possible add it to end of last comment. So people can add more than one comment.

  6. #6
    Valued Forum Contributor bulina2k's Avatar
    Join Date
    11-20-2012
    Location
    Urziceni, Ialomita, Romania
    MS-Off Ver
    2019 and 365
    Posts
    861

    Re: Place text in a specific cell based on two separate drop down list entries

    try this code under your button:
    Please Login or Register  to view this content.
    Last edited by bulina2k; 06-23-2015 at 04:22 PM.
    .. and don't forget to have fun!
    Bogdan.

    mark SOLVED and Add Reputation if my answer pleases you

  7. #7
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,717

    Re: Place text in a specific cell based on two separate drop down list entries

    click enter and for the full term to appear in column F
    How do you look up the full term if you know the code?

    Here is a solution that enters the code. You can use formulas in column F to show the full term, but you will need a table giving every code and its corresponding full term.
    Attached Files Attached Files

  8. #8
    Registered User
    Join Date
    07-16-2014
    Location
    England
    MS-Off Ver
    2010
    Posts
    25

    Re: Place text in a specific cell based on two separate drop down list entries

    Many thanks for your reply. The table is not finished but eventually column I (Intervention Short Code) will be populated with about 20 similar 'codes' (shorter versions of the full message) and each Short Code will have its corresponding message in column J (Intervention). It was my intention to populate the cell in column F with with the full message (column J).

    Eg. If the user selects 'name 12' in G3 and 'DT for HL' in G4 and clicks enter then F14 (name 12 in column A) will show the message "A number of detentions set as a result of incomplete Home Learning".

    What formula could I use in column F to achieve this? Would a VLOOKUP work?

    Really appreciate your help.

  9. #9
    Valued Forum Contributor bulina2k's Avatar
    Join Date
    11-20-2012
    Location
    Urziceni, Ialomita, Romania
    MS-Off Ver
    2019 and 365
    Posts
    861

    Re: Place text in a specific cell based on two separate drop down list entries

    have you tried my code?
    for 20 short codes it becomes:
    Please Login or Register  to view this content.

  10. #10
    Registered User
    Join Date
    07-16-2014
    Location
    England
    MS-Off Ver
    2010
    Posts
    25

    Re: Place text in a specific cell based on two separate drop down list entries

    Bulina2K, I must apologise. I tried your code on my original spreadsheet (one uploaded here different due to sensitive info) and it did not work. I realise now this is because two columns are different. Your code works perfectly on uploaded spreadsheet providing me with correct value in column F.

    Thank you both very much.

    Quick question: Using your code Bulina2K, if I enter two different pieces of information to the same name, the two messages are split by a line. For formatting purposes only, is there a way I can get them to be split by a space instead?

  11. #11
    Valued Forum Contributor bulina2k's Avatar
    Join Date
    11-20-2012
    Location
    Urziceni, Ialomita, Romania
    MS-Off Ver
    2019 and 365
    Posts
    861

    Re: Place text in a specific cell based on two separate drop down list entries

    sure! replace
    Please Login or Register  to view this content.
    with
    Please Login or Register  to view this content.

  12. #12
    Registered User
    Join Date
    07-16-2014
    Location
    England
    MS-Off Ver
    2010
    Posts
    25

    Re: Place text in a specific cell based on two separate drop down list entries

    Hmm, I've tried to copy your code above to my original spreadsheet but it is not working. I have copied into as a new sub and assigned the macro to the button. All of the information is in exactly the same places as the example I uploaded and the only difference is the Name 1 etc are actually names. Any ideas why this is not working now? Is there something in the code which relates solely to that example sheet??

  13. #13
    Valued Forum Contributor bulina2k's Avatar
    Join Date
    11-20-2012
    Location
    Urziceni, Ialomita, Romania
    MS-Off Ver
    2019 and 365
    Posts
    861

    Re: Place text in a specific cell based on two separate drop down list entries

    Maybe there's a reference problem. Let me e try to explain the code so you can adjust to fit your file:

    here the 'name' variable searches in the A3:A30 range for the G3 value and takes the range address of the found value. The xlWhole parameter implies that the entire content of the searched cell is exactly the value in G3
    Please Login or Register  to view this content.

    If still unclear please upload file.

+ 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. Replies: 4
    Last Post: 09-16-2014, 09:38 AM
  2. Replies: 19
    Last Post: 04-10-2013, 08:30 AM
  3. Replies: 3
    Last Post: 02-26-2013, 12:54 PM
  4. Replies: 6
    Last Post: 04-20-2010, 07:08 AM
  5. Value for text entries from dependant drop down list
    By BakerD in forum Excel General
    Replies: 2
    Last Post: 02-19-2009, 09:36 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