Consulting

Results 1 to 5 of 5

Thread: Combobox and LinkedCell issue

  1. #1
    VBAX Contributor Glaswegian's Avatar
    Joined
    Sep 2004
    Location
    Glasgow, Scotland
    Posts
    196
    Location

    Combobox and LinkedCell issue

    Hi

    I'm having an issue setting the LinkedCell value in a combobox. The box is on a sheet and the ListFillRange and LinkedCell will change depending on the choice of 2 checkboxes. Therefore if checkbox 1 is selected then the user should see values from list A in the box; if checkbox 2 is selected then it should be values from list B. The LinkedCell value is then used later and copied to another sheet. Rows are hidden or unhidden on this other sheet depending on the checkbox selection.

    I am able to change the ListFillRange with no problems, but the LinkedCell refuses to change.
    [vba]Private Sub CheckBox9_Click()
    Dim myCB As OLEObject

    If [AC11] = True Then [AD11] = False
    If [AD11] = True Then [AC11] = False

    Set myCB = Sheets("FRCM").OLEObjects("Combobox5")

    If CheckBox9 = True Then
    With myCB
    .ListFillRange = "TypeCB"
    .LinkedCell = Sheets("FRCM").Range("AH26")
    .Object.ListIndex = -1
    End With
    With Sheets("GB5420 FRCM")
    .Rows("31:32").Hidden = True
    .Rows("33:34").Hidden = False
    End With
    Else
    With myCB
    .ListFillRange = "TypeYB"
    .LinkedCell = Sheets("FRCM").Range("AH21")
    .Object.ListIndex = -1
    End With
    With Sheets("GB5420 FRCM")
    .Rows("33:34").Hidden = True
    .Rows("31:32").Hidden = False
    End With
    End If
    End Sub[/vba]
    I'm guessing it's something to do with the combobox Property, but I really don't understand why ListFillRange works and LinkedCell does not.

    Any help greatly appreciated - thanks.
    Iain - XL2010 on Windows 7

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    [vba]

    Private Sub CheckBox9_Click()
    Dim myCB As OLEObject

    If [AC11] = True Then [AD11] = False
    If [AD11] = True Then [AC11] = False

    Set myCB = Sheets("FRCM").OLEObjects("Combobox5")

    If CheckBox9 = True Then
    With myCB
    .ListFillRange = "TypeCB"
    .LinkedCell = Sheets("FRCM").Range("AH26").Address
    .Object.ListIndex = -1
    End With
    With Sheets("GB5420 FRCM")
    .Rows("31:32").Hidden = True
    .Rows("33:34").Hidden = False
    End With
    Else
    With myCB
    .ListFillRange = "TypeYB"
    .LinkedCell = Sheets("FRCM").Range("AH21").Address
    .Object.ListIndex = -1
    End With
    With Sheets("GB5420 FRCM")
    .Rows("33:34").Hidden = True
    .Rows("31:32").Hidden = False
    End With
    End If
    End Sub
    [/vba]

    BTW, are you the same guy that administers TechSupportForum?
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    VBAX Contributor Glaswegian's Avatar
    Joined
    Sep 2004
    Location
    Glasgow, Scotland
    Posts
    196
    Location
    Superb! Thanks.

    Why did the code need "Address"?

    BTW, are you the same guy that administers TechSupportForum?
    Lol - I'm just a Mod at TSF - nothing as lofty as an Admin...
    Iain - XL2010 on Windows 7

  4. #4
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    It needed address because you want the address string, otherwise it defaults to value. That is why it is ALWAYS best to use the full declaration of a property, not let it default.

    Mod or Admin, it is a worthy site, so congratulations on your efforts.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  5. #5
    VBAX Contributor Glaswegian's Avatar
    Joined
    Sep 2004
    Location
    Glasgow, Scotland
    Posts
    196
    Location
    Quote Originally Posted by xld
    It needed address because you want the address string, otherwise it defaults to value. That is why it is ALWAYS best to use the full declaration of a property, not let it default.
    Ah, of course - thanks. I don't do enough Excel these days so I've propbably slipped into somne bad habits.

    Quote Originally Posted by xld
    Mod or Admin, it is a worthy site, so congratulations on your efforts.
    Thanks for that - we try our best.
    Iain - XL2010 on Windows 7

Posting Permissions

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