ComboBox - strange behaviour - how to format date when "textcolumn" and "boundcolumn" are different?

Jamualson

Board Regular
Joined
Feb 17, 2021
Messages
145
Office Version
  1. 2019
Platform
  1. Windows
(detailed edited picture enclosed)

The format date function works well when the combobox text (text at the top) and the value (linked cell) are referring to the same data and the datatype is date.

However, if i seperate them, so
- .TextColumn (text at the top) will be column 1 (string) and
- .BoundColumn will be column 2 (date)

then the format function throws an "Invalid property value" error. (no matter if I want to set the Value by formatting the text property, or want to set the value property by setting the text property, or setting text property by formatting text property)
1618253917700.png


I guess I don't really understand the "Text" and "value" property. I would just think one of them is the text on the top of combobox (text) and other is the linked cell value (value property).

But it seems to me that they are somehow not independent from each other. But I don't understand exactly why and how could I set the "Text" property to a formatted date from the data set and how to set linked cell to a completely other data type.

Thank you very much, I am really confused by this one.



1618253143888.png


VBA Code:
Private Sub ComboBox1_Change()

    ComboBox1.Value = Format(ComboBox1.Text, "dd/mmm/yyyy")               'THIS line throws the error:/
 
End Sub


Sub test()

    With MySheet.ComboBox1
     
        .ListFillRange = "A1:B5"
        .LinkedCell = Range("G8").Address
        .ColumnCount = 2
     
        .TextColumn = 1                     'text showing as selected at the top
        .BoundColumn = 2                    'linked cell value

    End With
                                                 
End Sub
 
Last edited:

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college

Forum statistics

Threads
1,214,649
Messages
6,120,732
Members
448,987
Latest member
marion_davis

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top