Dynamically set ListFillRange in Excel ComboBox

后端 未结 7 796
忘了有多久
忘了有多久 2020-12-01 22:40

I tried doing something like:

 cmbMyBox.ListFillRange = \"E2\"

But the combobox does not seem to populate.

7条回答
  •  孤街浪徒
    2020-12-01 23:41

    Ok, don't mean to answer my own question again but this ListFillRange property on combobox for Excel was absolutely maddening. Here's the final code that I implemented.

       Sheet1.Range("E3").CurrentRegion.Select
       Dim example as Range
       Set example = Selection
    
       With cmbMyBox
         .ListFillRange = example.Address(0, 0, x1A1, True)
       End With
    

    The trouble here was that I was trying to dynamically set the combobox using a dynamic range which changes depending on what user inputted values were given. As far as I understand I couldn't use a named range because named ranges are FIXED, e.g (A3:Z20) and cannot be adjusted.

提交回复
热议问题