Date formats in userform text boxes

mmmreece

New Member
Joined
Apr 8, 2015
Messages
32
Hi . I know that if I format a text box to Format(textbox1, "MM/DD/YYYY") it will enter the value as a date if textbox1 is initialised as textbox1 = Date but what I would like to do is have textbox1 show the date on the userform as "DDD dd/mm/yyyy" but when entered into a cell enters it as a date into the spreadsheet. I currently have a command button to enter called CMB_Enter which has the formula (one of the many) of Range ("A" & NewRow).value = textbox1.value. I'm having difficulty in achieving this. One workaround I have is to have an invisible textbox showing the date in format "mm/dd/yyyy" but surely there should be a way to display a userform textox as one format and then enter the actual value from that textbox to a cell.

Also there is another issue I have here. Sometimes I need to enter a different date into the textbox but if the textbox is formatted in a different way then I don't know how to enter a different date!
I've tried to be concise here but if what I'm saying doesn't make any sense let me know and I'll try and re-word it. Unfortunately googling for this just brings me up too much irrelevant stuff for me to find anything
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
Hi,

try following & see if does what you want

VBA Code:
Private Sub CMB_Enter_Click()


With Range("A" & NewRow)
    .Value = DateValue(Mid(Me.TextBox1.Value, 4))
    .NumberFormat = "mm/dd/yyyy"
End With

End Sub

this assumes that your textbox date is displaying in format "DDD dd/mm/yyyy" - If no valid date entered, code will error.

Dave
 
Upvote 0

Forum statistics

Threads
1,213,532
Messages
6,114,177
Members
448,554
Latest member
Gleisner2

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