+ Reply to Thread
Results 1 to 11 of 11

Default value in a cell from data validation list

  1. #1
    Registered User
    Join Date
    02-11-2023
    Location
    Dhaka
    MS-Off Ver
    19
    Posts
    17

    Default value in a cell from data validation list

    Hi,

    I am trying to show a default value in a cell from data validation list using VBA. It works if the list is in the same sheet (Sheet1) but it doesn't if the list is in other sheet (Fruits here).

    Can anyone assist me to make it work from the list in other sheet, please?

    With regards,
    Md Mahfuzur Rahman

  2. #2
    Forum Expert torachan's Avatar
    Join Date
    12-27-2012
    Location
    market harborough, england
    MS-Off Ver
    Excel 2010
    Posts
    4,411

    Re: Default value in a cell from data validation list

    I found it difficult to understand fully what you were trying to achieve as there would have been a need to make a second choice dependant upon the first choice made - so have offered the following as I think this is what you are trying to do.
    However I may be completely wrong ??????
    Try the attached using 'structured tables' - all the data and choices you make stay within the confines of the table - there is no need to extend the data validation this occurs dynamically as the tables expand/contract.
    Look in the 'name manager' to understand the process - the teacher name list is taken from the table headers - then a relationship is established between each column and an index is established to determine which column is read into the subject list.
    Refer to the data validation setup and you will see the reference names that are called for the list of each validation.
    To start the table first put a 'full stop' (point) in cell 'A2' move to 'B2' and back to 'A2' then make your two choices - to extend the table repeat in 'A3'>'B3'>'A3'
    Attached Files Attached Files
    Torachan,

    Mission statement; Promote the use of Tables, Outlaw the use of 'merged cells' and 'RowSource'.

  3. #3
    Registered User
    Join Date
    02-11-2023
    Location
    Dhaka
    MS-Off Ver
    19
    Posts
    17

    Re: Default value in a cell from data validation list

    Hi Torachan,

    This does not go with my problem. I need it to select any value rather than default value. The value of first cell comes based on value of other cell which is also selectable.

    Regards,
    Md Mahfuzur Rahman

  4. #4
    Forum Expert torachan's Avatar
    Join Date
    12-27-2012
    Location
    market harborough, england
    MS-Off Ver
    Excel 2010
    Posts
    4,411

    Re: Default value in a cell from data validation list

    Explain a little clearer - your initial post quotes quite clearly---

    I am trying to show a default value in a cell from data validation list

  5. #5
    Registered User
    Join Date
    02-11-2023
    Location
    Dhaka
    MS-Off Ver
    19
    Posts
    17

    Re: Default value in a cell from data validation list

    Hi,

    I want to show default value from validation list in one of my projects. Please see the sample file. Cell B4 is validated with drop down list. On every selection there comes the third number of objects from respective drop down list, later I can change the value from the list as I require. The default value comes if the drop down list lies in same sheet. It does not show the default value if the list lies in other sheet. Please check the "Fruits" and "Fruits1" items. Fruits1 shows the default value "Mango" in cell C4 from drop down list but Fruits does not show the default value "Mango" from the list in next sheet, the drop down list comes but default value is not shown.
    I hope I was able to make you clear.

    Regards,
    Md Mahfuzur Rahman

  6. #6
    Valued Forum Contributor
    Join Date
    08-08-2022
    Location
    Buenos Aires
    MS-Off Ver
    Excel 2019
    Posts
    1,777

    Re: Default value in a cell from data validation list

    Hello, mahfuz89. Replace what you have with this other:

    PHP Code: 
    Public Sub Worksheet_Change(ByVal Target As Range)
    If 
    Target.Address <> "$B$4" Then Exit Sub
    With Target
    (, 2)
      .
    Validation.Delete
      
    .Validation.Add Type:=xlValidateListFormula1:="=" Target
      
    .Value ThisWorkbook.Names(Target.Value).RefersToRange(3)
    End With
    End Sub 
    You are always very welcome if you add reputation by clicking the * (bottom left) of each message that has helped you.

  7. #7
    Registered User
    Join Date
    02-11-2023
    Location
    Dhaka
    MS-Off Ver
    19
    Posts
    17

    Re: Default value in a cell from data validation list

    Hello Beyond Excel,

    I would like to convey my deepest gratitude for the invaluable support you provided me in resolving my recent problem. Your response and helpful solution made a huge difference in my project.

    I was facing a difficult problem and was unsure of where to turn for help. However, the assistance provided by your forum was truly amazing. Your knowledge and expertise in the field helped me find a solution that I would never have been able to achieve on my own. The clarity and simplicity of the solution provided were greatly appreciated, as well as the promptness of the response. I am truly thankful for the effort you put in to help me out and for taking the time to share your knowledge and expertise.

    Once again, thank you very much for your help. You have provided me with an invaluable service, and I will not hesitate to recommend your forum to others in need of similar assistance in the future. All the best.

    E.g. I was trying to reply you on the day you sent me the code but the mail bounced back.

    Sincerely,
    Md Mahfuzur Rahman

  8. #8
    Valued Forum Contributor
    Join Date
    08-08-2022
    Location
    Buenos Aires
    MS-Off Ver
    Excel 2019
    Posts
    1,777

    Re: Default value in a cell from data validation list

    Quote Originally Posted by mahfuz89 View Post
    E.g. I was trying to reply you on the day you sent me the code but the mail bounced back.

    Sincerely,
    Md Mahfuzur Rahman
    Mahfuzur: You have been so generous in your concepts and so grateful that... who cares to wait a little longer or a little less! It isn't true?...

    Greetings and until next time.

  9. #9
    Registered User
    Join Date
    02-11-2023
    Location
    Dhaka
    MS-Off Ver
    19
    Posts
    17

    Re: Default value in a cell from data validation list

    Hello,

    Are you Craig Hatmaker from Beyond Excel? If this is you then I found you in you tube and great to see you.
    Greetings to you as well. Regards,
    Last edited by mahfuz89; 02-27-2023 at 04:14 PM.

  10. #10
    Valued Forum Contributor
    Join Date
    08-08-2022
    Location
    Buenos Aires
    MS-Off Ver
    Excel 2019
    Posts
    1,777

    Re: Default value in a cell from data validation list

    .

    Quote Originally Posted by mahfuz89 View Post
    Are you Craig Hatmaker from Beyond Excel? If this is you then I found you in youtube and great to see you.
    Not really: I'm much prettier and much younger... (Ja ja ja)

  11. #11
    Registered User
    Join Date
    02-11-2023
    Location
    Dhaka
    MS-Off Ver
    19
    Posts
    17

    Re: Default value in a cell from data validation list

    Hello,

    Greetings!
    I need to get a default value from its drop down list in cell E11 based on the value in cell B11. The drop down list changes while changing the selection in cell C10 but the default value does not show, shows previous value. I have used a macro.
    Please assist.

    With regards,
    Md Mahfuzur Rahman
    Attached Files Attached Files

+ 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. [SOLVED] Default value of a cell determined by List in Data Validation.
    By Trond64 in forum Excel Formulas & Functions
    Replies: 11
    Last Post: 07-11-2021, 10:22 AM
  2. [SOLVED] set a default value in dropdoen list data validation
    By aparunkumar in forum Excel General
    Replies: 5
    Last Post: 04-07-2017, 11:37 AM
  3. [SOLVED] Setting default value in Data Validation List
    By frenurks in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 11-27-2015, 01:05 PM
  4. [SOLVED] make list in Data Validation default to top value?
    By zhunter71 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-11-2015, 03:36 AM
  5. [SOLVED] Data validation list default value disappears!
    By ShoshanaM in forum Excel General
    Replies: 5
    Last Post: 12-05-2012, 07:18 PM
  6. Data Validation > List > Default Entry?
    By BuRn3R in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-26-2009, 06:49 PM
  7. Default Cell Value with Validation Drop-Down List
    By Dave H in forum Excel General
    Replies: 0
    Last Post: 01-30-2006, 05:00 PM

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