Userform CB Date Value

paldob

New Member
Joined
Apr 23, 2018
Messages
28
Good Evening,

I have created a userform that details every Monday Date for the year 2018. If I tick a cb, I want the specific Monday date to be input into Worksheets("Weekly Stats") .Range("B2")

As below, I have the code for cb15Jan_click. This puts the value of 15/01/2018 into the correct worksheet and cell. However, it gets put in as text value and messes up all of my VLookup & Index formula's. How could I have this input as a Date format automatically?

Code:
Private Sub cb15Jan_Click()
With Me
    If cb15Jan.Value = True Then
    Worksheets("Weekly Stats").Range("B2").Value = "15/01/2018"
    End If
End With
End Sub

Kind regards
Pal
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
try this:

Code:
Private Sub cb15Jan_Click()
If Cb15Jan Then Sheets("Weekly Stats").Range("B2").Value = CDate("15/01/2018")
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,653
Messages
6,120,751
Members
448,989
Latest member
mariah3

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