+ Reply to Thread
Results 1 to 1 of 1

Issue With ControlFormat.List When Changing the Input Range In a Form ComboBox

  1. #1
    Registered User
    Join Date
    02-20-2022
    Location
    Riverview, FL
    MS-Off Ver
    At Home:Office 2013 At Work: Office 365
    Posts
    1

    Issue With ControlFormat.List When Changing the Input Range In a Form ComboBox

    The attached workbook contains 2 macros, both of which do the same thing... toggle the Input Range of a Forms Control ComboBox between two named ranges.

    Macro_1 declares the variables Rng1 and Rng2 as Ranges, and Sets them to = range("Name"). Then it alternately toggles which range is set as the Combobox Input Range using ControlFormat.List:

    With ActiveSheet.Shapes("RngSelection").ControlFormat
    .List = Rng1
    .DropDownLines = Rng1RowCount
    End With

    Macro_2 performs the same task in a slightly different way. Rng1 and Rng2 are declared as strings, and only the range name strings are assigned to them. In this example, the Input Range toggle is accomplished with ControlFormat.ListFillRange:

    With ActiveSheet.Shapes("RngSelection").ControlFormat
    .ListFillRange = Rng1
    .DropDownLines = Rng1RowCount
    End With



    The issue with Macro_1 is that this method leaves the Input Range blank under the Control tab in the ComboBox Format Control dialog box. I don't know if this is the case with all earlier versions of Excel, but I do know it is the case with Excel365 and Excel 2013.

    Despite this glitch, the approach of Macro_1 functions as expected and has for years through several version iterations of Excel. However, in Excel365 there is an added twist. In the 365 version, when the workbook is saved and later reloaded, the ComboBox initially displays a blank (presumably because the Input Range is blank?). But as soon as you click on the Down Arrow, the selected item appears and the Combobox then functions as expected.

    In all previous versions of Excel we have used, the selected item appeared in the Combobox as expected upon initial loading of the workbook, even though the Input Range in the Format Control dialog box is left blank by Macro_1. This is why this glitch wasn't previously apparent.

    I know... very minor. But it annoyed me, so I've spent the better part of two work shifts trying to figure out what is going on.

    I came up with the solution used in Macro_2 through much Googling and experimentation. This routine properly sets the Input Range for the Combobox each time it's toggled. So, I don't need help with a solution. But I could use some help understanding why Macro_1 leaves the Input Range blank.

    Is ControlFormat.List used improperly in Macro_1?
    Or is it just an unsupported use?
    Or is it just an Excel bug?

    I have read some suggestions that ControlFormat.ListFillRange sometimes behaves unpredictably, and advice to avoid using it if possible. Does anyone see a potential issue with it's use in Macro_2?

    As a final point of curiosity, you can click on the Switch List Macro1 button repeatedly, and you will see the switch is being performed. Then you can move on to clicking the Switch List Macro2 button repeatedly, and it will continue switching as expected. However, after clicking the Macro2 button, if you then go back and click the Macro1 button, the CellLink Value (at C5) goes to zero, and the ComboBox displays a blank. The ComboBox is still functional however, and you can click the down arrow to make a new selection.

    I just wonder why I can go from Macro1 to Macro2 with no issues, but not the other way around?

    Thanks in advance for any input give to this topic.

    Herman
    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. Dynamic Changing UserForm Combobox List
    By MiguelSPerera in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-03-2019, 09:43 AM
  2. manual changing of keys in combobox list
    By Nitzan in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-02-2014, 05:22 AM
  3. Changing Combobox for valid dates from a list
    By Nitzan in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 03-25-2014, 05:37 PM
  4. Replies: 0
    Last Post: 03-18-2013, 08:43 PM
  5. [SOLVED] Having trouble changing a combobox fill list with a macros
    By pheonix0 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-17-2012, 02:05 PM
  6. Changing background color of a combobox list entry
    By Schwizer in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-22-2007, 11:01 AM
  7. [SOLVED] Shape ControlFormat.LinkedCell returns wrong Address for named range - BUG
    By bowlegtroy@hotmail.com in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 07-14-2006, 10:10 AM

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