display date instead of number

RPT_22

Board Regular
Joined
Sep 18, 2012
Messages
98
Hi

I am using a combobox on my userform to select a date
The combobox currently has 3 options for dates:
18/11/2021
19/11/2021
20/11/2021
The combobox look at a sheet which has the 3 dates [cells are formatted as date]
=today()-2
=today()-1
=today()
The issue i have is the dates are displayed correctly in the userform combobox but when i select a date such as 20/11/2021 it is displayed as 44520 in the combobox but does transfer onto a sheet as a date
How do i fix this so the actual date is displayed in the combobox?

Other option: Is there a vba code for displaying the dates in the userform combobox which uses vba code therefore no need to look at another sheet for the dates

Thanks
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
Hi
Try this method
VBA Code:
Private Sub UserForm_Initialize()
Me.ComboBox1.List = Application.Transpose(Sheets("sheet1").Range("N1:N3").Value)
End Sub
 
Upvote 0
Thank you
Where do i place the code as i get the following error. Commandbutton2 is on a sheet called Data_Entry and opens the userform

Private Sub CommandButton2_Click()
Pressure_Test.Show [this is highlighted yellow]
End Sub

Thank you
 
Upvote 0
Is Pressure_Test the name of Userform?
And have you changed this
VBA Code:
Sheets("sheet1").Range("N1:N3").Value
I mean sheet1 and the range you are using?
 
Upvote 0
Hi
Yes Pressure_Test is the name of Userform
Yes i did change the values and sheet name

Thank you
 
Upvote 0
Untitled.png
 
Upvote 0
hi

I inserted the code in the forms folder [Pressure_Test userform]

Commandbutton2 code which opens the userform is in sheet2

Thank you
 

Attachments

  • VBA.png
    VBA.png
    6.9 KB · Views: 9
  • vba-1.png
    vba-1.png
    7.4 KB · Views: 9
Upvote 0

Forum statistics

Threads
1,214,385
Messages
6,119,209
Members
448,874
Latest member
b1step2far

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