UserForm Dates

ZaneCOYS

New Member
Joined
Nov 23, 2010
Messages
24
Hi,

I have created a userform and have set it up so the user will add the date by selecting the day on a listbox1, month listbox2 and year listbox3.

This seems to work but I think it would look cleaner if I could set the user form to have todays date as default but if this date needs to be changed then the user can. Here I am happy to take further advice and either use the listboxes as I have or a drop down calender if possible.

This is what I have at the moment.

Code:
[Code] Private Sub CommandButton1_Click()
If ListBox100.Value = "" Or ListBox3.Value = "" Or ListBox4.Value = "" Or ListBox5.Value = "" Then
MsgBox "Please Ensure all Required Fields are completed before progressing"
Exit Sub
End If
If ListBox2.Value = "" Then
MsgBox "Please Ensure all Required Fields are completed before progressing"
Exit Sub
End If
 
Worksheets("Working").Cells(2, 1).Value = ListBox100.Value 'Name
Worksheets("Working").Cells(2, 2).Value = ListBox3.Value 'day
Worksheets("Working").Cells(3, 2).Value = ListBox4.Value 'month
Worksheets("Working").Cells(4, 2).Value = ListBox5.Value 'year
Worksheets("Working").Cells(4, 1).Value = TextBox6.Value 'ref
Worksheets("Working").Cells(5, 1).Value = ListBox2.Value 'work type
Worksheets("Working").Cells(6, 1).Value = TextBox5.Value ' notes
Unload Me
End Sub

As you can see I currently have error msg if the date fields are not completed so would need to bypass this if the default date is used.
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
so work around this by using the following formula in the data sheet,

Code:
=IF(ISERROR(DATEVALUE(B2&B3&B4)),NOW(),DATEVALUE(B2&B3&B4))

This sets the date to now by default
 
Last edited:
Upvote 0

Forum statistics

Threads
1,216,052
Messages
6,128,509
Members
449,455
Latest member
jesski

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