+ Reply to Thread
Results 1 to 7 of 7

Option button returning compile error

  1. #1
    Registered User
    Join Date
    05-10-2012
    Location
    Los Angeles
    MS-Off Ver
    Excel 2010
    Posts
    36

    Option button returning compile error

    Hi Excelforums,

    I'm getting the compile error: "wrong number of arguments or invalid property assignment" on the first line of the vba code for an option button:


    Private Sub OptionButton1_Click() <----- highlighted line
    If OptionButton1.Value = True Then
    Set Shapes("Combobox1").ControlFormat.ListFillRange = "uniquecompanylist"
    End Sub


    Though I suspect the problem lies somewhere other than the 1st line.
    Last edited by ObiWanBaloney; 06-05-2012 at 05:11 PM.

  2. #2
    Valued Forum Contributor tlafferty's Avatar
    Join Date
    04-08-2011
    Location
    United States, Tacoma, WA
    MS-Off Ver
    Excel 2010, Excel 2013 Customer Preview
    Posts
    1,112

    Re: Option button returning compile error

    As a minimum, you need an End If statement after your line that contains the Set Shapes. Also, I'm not sure how you're bringing in what I assume to be a named range "uniquecompanylist" but I suspect that line will also fail.
    If your question has been satisfactorily addressed, please consider marking it solved. Click the Thread Tools dropdown and select Mark thread as solved.
    Also, you might want to add to the user's reputation by clicking the star icon in the lower left corner of the post with the answer- it's why we do what we do...

    Thomas Lafferty
    Analyst/Programmer

  3. #3
    Valued Forum Contributor tlafferty's Avatar
    Join Date
    04-08-2011
    Location
    United States, Tacoma, WA
    MS-Off Ver
    Excel 2010, Excel 2013 Customer Preview
    Posts
    1,112

    Re: Option button returning compile error

    Note - the above is untested, so there may be other things wrong as well.

  4. #4
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Option button returning compile error

    listfillrange is a string property so lose the 'Set' part.
    Josie

    if at first you don't succeed try doing it the way your wife told you to

  5. #5
    Registered User
    Join Date
    05-10-2012
    Location
    Los Angeles
    MS-Off Ver
    Excel 2010
    Posts
    36

    Re: Option button returning compile error

    tlafferty: Yeah, as expected, that line is having problems and "uniquecompanylist" is indeed a named range. Is there a proper way to change listfillrange via macro?

    JosephP: I dropped the set part. Still doesn't work though as kinda expected.


    Private Sub OptionButton1_Click()
    If OptionButton1.Value = True Then
    Shapes("Combobox1").ControlFormat.ListFillRange = "uniquecompanylist" <---------- highlighted line
    End If
    End Sub


    The new error is "object doesn't support this property or method".

  6. #6
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Option button returning compile error

    you didn't say what type of control but probably
    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    05-10-2012
    Location
    Los Angeles
    MS-Off Ver
    Excel 2010
    Posts
    36

    Re: Option button returning compile error

    Work perfectly, thanks a bunch!

+ 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