+ Reply to Thread
Results 1 to 3 of 3

drop down box. IF function

  1. #1
    Registered User
    Join Date
    01-07-2021
    Location
    Nottingham, England
    MS-Off Ver
    2016
    Posts
    24

    drop down box. IF function

    Hi,

    So i have a userform that was working fine, I now want the drop down list items to show certain values based on another combobox`s value.

    The previous list was determined by the following code:

    Private Sub UserForm_initialize()

    cmbDEESHACKLE.List = Split("SSLRDS0.33,SSLRDS0.50,SSLRDS0.75,SSLRDS1.00,SSLRDS2.00,SSLRDS3.00,SSLRDS4.00,SSLRDS5.00,SSLRDS6.00", ",")

    Now I thought it would be as simple as putting:

    If cmbEYEB.List = "M10" Then

    cmbDEESHACKLE.List = Split("SSLRDS0.33", "SSLRDS0.5", "SSLRDS0.75", "SSLRDS1.0", ",")
    Else
    End If


    But when I do it comes up with an error

    "Wrong number of arguments or invalid property assignment"





    The full code proposed is:


    Private Sub cmbEYEB_Change()

    If cmbEYEB.List = "M10" Then

    cmbDEESHACKLE.List = Split("SSLRDS0.33", "SSLRDS0.5", "SSLRDS0.75", "SSLRDS1.0", ",")

    End If

    If cmbEYEB.List = "M12" Then

    cmbDEESHACKLE.List = Split("SSLRDS0.33", "SSLRDS0.50", "SSLRDS0.75", "SSLRDS1.00", ",")
    Else
    End If

    If cmbEYEB.List = "M16" Then

    cmbDEESHACKLE.List = Split("SSLRDS0.33", "SSLRDS0.50", "SSLRDS0.75", "SSLRDS1.00", "SSLRDS2.00", "SSLRDS3.00", ",")
    Else
    End If

    If cmbEYEB.List = "M20" Then

    cmbDEESHACKLE.List = Split("SSLRDS0.33", "SSLRDS0.50", "SSLRDS0.75", "SSLRDS1.00", "SSLRDS2.00", "SSLRDS3.00", "SSLRDS4.00", "SSLRDS5.00", ",")
    Else
    End If

    If cmbEYEB.List = "M24" Then

    cmbDEESHACKLE.List = Split("SSLRDS0.33", "SSLRDS0.50", "SSLRDS0.75", "SSLRDS1.00", "SSLRDS2.00", "SSLRDS3.00", "SSLRDS4.00", "SSLRDS5.00", ",")
    Else
    End If

    If cmbEYEB.List = "M30" Then

    cmbDEESHACKLE.List = Split("SSLRDS0.33", "SSLRDS0.50", "SSLRDS0.75", "SSLRDS1.00", "SSLRDS2.00", "SSLRDS3.00", "SSLRDS4.00", "SSLRDS5.00", ",")
    Else
    End If

    If cmbEYEB.List = "M36" Then

    cmbDEESHACKLE.List = Split("SSLRDS0.33", "SSLRDS0.50", "SSLRDS0.75", "SSLRDS1.00", "SSLRDS2.00", "SSLRDS3.00", "SSLRDS4.00", "SSLRDS5.00", ",")
    Else
    End If



    End Sub



    Any ideas

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

    Re: drop down box. IF function

    upload your workbook - it is bad practice to hard code your list variables - put them into a sheet list then load your comboboxes from the sheet list.
    p.s. please put your code between code tags so that we can run it in formatted form as required.
    Torachan,

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

  3. #3
    Registered User
    Join Date
    01-07-2021
    Location
    Nottingham, England
    MS-Off Ver
    2016
    Posts
    24

    Re: drop down box. IF function

    Hi,

    As soon as I read that it clicked! Sorted it now, thanks for your reply.

    Yes I am new to all this VBA stuff - I am even surprised how far along I am with this sheet I`ve created!

    Thanks

+ 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. Drop down table with function of drop down list
    By jankrulak in forum Excel General
    Replies: 0
    Last Post: 04-29-2020, 11:46 AM
  2. Using a drop down list as a go to function
    By motecben in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 06-26-2019, 10:57 AM
  3. Use drop-down value as function value
    By skydivetom in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 05-07-2019, 11:01 PM
  4. Need Function to yes or no drop down box
    By Dawna Williamson in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 08-31-2014, 01:40 PM
  5. [SOLVED] Drop Down function
    By kokoo in forum Excel General
    Replies: 5
    Last Post: 12-13-2012, 01:05 AM
  6. Excel 2008 : Drop down function
    By JJORD2 in forum Excel General
    Replies: 5
    Last Post: 09-17-2011, 08:52 PM
  7. Is a Drop Down box the best function to use?
    By Ant in forum Excel General
    Replies: 2
    Last Post: 05-20-2005, 06:06 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