Consulting

Results 1 to 14 of 14

Thread: need Code to select value from dropdown list using numeric values

  1. #1
    VBAX Regular
    Joined
    Sep 2022
    Posts
    7
    Location

    need Code to select value from dropdown list using numeric values

    Please send me code to the following example:
    There is a column with dropdown list to select values e.g. A1 to A10 have dropdown lists with values "aaaaaa","bbbbb","cccccc","dddddd","eeeee"
    There are numeric values from B1 to B10. between 0 to 4
    The code or function must read values from column B and select values in Column A accordingly.
    If B2 has 2, the value of A2 should be "cccccc" or If B3 has 0, the value of A2 should be "aaaaaa"
    Thank You in Advance

    Gamini

  2. #2
    you may try this.
    Attached Files Attached Files

  3. #3
    VBAX Regular
    Joined
    Sep 2022
    Posts
    7
    Location

    : need Code to select value from dropdown list using numeric values

    Thank you, a great job. There is a simple change. Can you please change the function to accept 5 parameters
    parameter 1 = Sheet2
    parameter 2 = Sheet1
    p3 = sheet 2 column
    p4 = sheet 1 column
    p5= number of cells


    The function read numeric values from par 1 and change combo boxes in sheet 1
    This is because I have around 1000 combo boxes in one sheet. So this could be a great help.
    See attached file
    Attached Files Attached Files
    Last edited by gamini; 09-28-2022 at 12:14 AM.

  4. #4
    Moderator VBAX Wizard Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    5,053
    Location
    Quote Originally Posted by gamini View Post
    There is a simple change. Can you please change the function to accept 5 parameters
    parameter 1 = Sheet2
    parameter 2 = Sheet1
    p3 = sheet 2 column
    p4 = sheet 1 column
    p5= number of cells
    This is not a "simple change" from your description.

    Parameter 1 = Sheet2. What on sheet 2 are we looking at? Your supplied file simply had a range of cells ( 0-5) in column A. Is this how your data is laid out?

    Parameter 2 = Sheet1. You indicated in post #3, that Sheet 1 has 1000 combo boxes but you have uploaded the file created by arnelgp as your example. That doesn't help us at all.

    Parameters 3 & 4, you reference a sheet number but not a column. Are we to guess the column number?

    The function read numeric values from par 1 and change combo boxes in sheet 1
    Have you changed your mind here? Arnelgp has supplied you already with a good answer to this issue

    This is because I have around 1000 combo boxes in one sheet. So this could be a great help.
    See attached file
    Your attached file does not reflect any of this. If you want our help ( and Im sure there are people here who would like to do so), you need to reconsider how you are going about this. Firstly, attach a real file, as in how you have your workbook set out. No, we don't need 1000 comboboxes on sheet1, and no, we don't need your actual data, just something that accurately reflects the type of data.
    Remember To Do the Following....
    Use [Code].... [/Code] tags when posting code to the thread.
    Mark your thread as Solved if satisfied by using the Thread Tools options.
    If posting the same issue to another forum please show the link

  5. #5
    VBAX Regular
    Joined
    Sep 2022
    Posts
    7
    Location
    Attached excel file has the real data. In sheet Ranking template has the same combobox in 301*22 cells. In sheet Input you have the numeric values. The function need to read the numeric values in the column"" and select the combobox value in sheet Ranking template accordingly.
    e.g. in sheet Input the person "Hon. Aravindh Kumar" has 1 in cell A2 then in sheet Ranking template "Hon. Aravindh Kumar" gets the value "High" (2nd value of the list).

    I have such around 120 such work-books.
    Sorry if I could't explain in earlier queries.

    Thank you all for helping
    Gamini
    Attached Files Attached Files
    Last edited by Aussiebear; 09-28-2022 at 10:41 PM. Reason: Tidyied up the post

  6. #6
    try to input some numbers on "Input" sheet.
    Attached Files Attached Files

  7. #7
    VBAX Regular
    Joined
    Sep 2022
    Posts
    7
    Location

    More Input

    As requested I have included more input. Please see attached file sample12.xlsm. Thank you for the patience and trying to help me.
    If You need more I will gladly do that.
    Attached Files Attached Files

  8. #8
    i added a "Button" on Input sheet for "force" update Ranking Template sheet.
    Attached Files Attached Files

  9. #9
    VBAX Regular
    Joined
    Sep 2022
    Posts
    7
    Location
    I did a test by adding values to col B toE
    colB all 0
    colC all 2
    colD all 3
    colE all 1
    Please check new file entries01.xlsm

    I clicked the button "Update Ranking Template Worksheet"

    But the values in "Ranking Template" didn't change.
    Did I do something wrong?
    Attached Files Attached Files

  10. #10
    what is the value of "very high", "Excellent", and "strongly agree"? is it 0?
    the vba uses 0 for the above ratings.

    also did you "enable" these warning messages?
    warn1.jpg

    and this message:

    warn2.jpg

    you should "Enable" all macro on your workbook.
    Attached Files Attached Files

  11. #11
    VBAX Regular
    Joined
    Sep 2022
    Posts
    7
    Location
    I changed the master Data
    5 Very High
    4 High
    3 Average
    2 Low
    1 Very Low
    0 Unknown

    Now for the Row "Hon. Aravindh Kumar" the macro changed all the columns to "Unknown" after clicking the button, but there are no changes to other fields
    Please see Entries02.xlsm. There were no warnings. Macros work fine.
    Sorry for troubling you..
    Attached Files Attached Files

  12. #12
    i import it to sample12.xlsm
    Attached Files Attached Files

  13. #13
    VBAX Regular
    Joined
    Sep 2022
    Posts
    7
    Location
    Working fine, Thank you so much. Really appreciate it.

  14. #14

Posting Permissions

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