Populate a text box based on the value of a combobox

kevinc1973

New Member
Joined
Jun 20, 2019
Messages
15
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

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off

Kenneth Hobson

Well-known Member
Joined
Feb 6, 2007
Messages
3,180
Office Version
  1. 365
Platform
  1. Windows
Code:
On Error Resume Next
  TextBox1.Value = Format(DateSerial(Year(Date), Month(Date), ComboBox3), "mm/dd/yy")
 
Last edited:

mikerickson

MrExcel MVP
Joined
Jan 15, 2007
Messages
24,079
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:

kevinc1973

New Member
Joined
Jun 20, 2019
Messages
15
Thank you for replying so quickly once I'm in front of the computer I will try the codes thanks again
 

kevinc1973

New Member
Joined
Jun 20, 2019
Messages
15
thank you Mikerickson that worked perfectly just what i wanted it to do. Thanks again
 

Forum statistics

Threads
1,148,108
Messages
5,744,878
Members
423,907
Latest member
zerocool88

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
Top