Populate a text box based on the value of a combobox

kevinc1973

New Member
Joined
Jun 20, 2019
Messages
22
Hi everyone,
I have a userform that has a textbox1 initialize with today's date(mm/dd/yyyy) and a combobox3 initialize with today's date format(dd). I am using the combobox3 to write to specific rows of the spreadsheet, when they need to make a change to a specific day's data they just change the combobox value to that day of the month. I would like to have textbox1 value change as well with the combobox value but in the full date format so there is one less thing to change. I was able to change the value by:

Private sub_combobox3_change
textbox1.value = combobox3.value
end sub

but it stays with just the "day". Is there any way to keep it the full date in textbox1?
Any help would be great thanks
Kevin
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
Code:
On Error Resume Next
  TextBox1.Value = Format(DateSerial(Year(Date), Month(Date), ComboBox3), "mm/dd/yy")
 
Last edited:
Upvote 0
It sounds like the ComboBox has the day information. The year and month information is only in the textbox

try

Code:
Private sub_combobox3_change
   Dim curDate as Date
   curDate = DateValue(Textbox1.Text)
   TextBox1.Text = Format(DateSerial(Year(curDate), Month(curDate), Val(ComboBox3.Text)), "mm/dd/yy")
end sub
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,893
Messages
6,175,248
Members
452,623
Latest member
cliftonhandyman

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