• Skip to main content
  • Skip to header right navigation
  • Skip to site footer

My Online Training Hub

Learn Dashboards, Excel, Power BI, Power Query, Power Pivot

  • Courses
  • Pricing
    • Free Courses
    • Power BI Course
    • Excel Power Query Course
    • Power Pivot and DAX Course
    • Excel Dashboard Course
    • Excel PivotTable Course – Quick Start
    • Advanced Excel Formulas Course
    • Excel Expert Advanced Excel Training
    • Excel Tables Course
    • Excel, Word, Outlook
    • Financial Modelling Course
    • Excel PivotTable Course
    • Excel for Customer Service Professionals
    • Excel for Operations Management Course
    • Excel for Decision Making Under Uncertainty Course
    • Excel for Finance Course
    • Excel Analysis ToolPak Course
    • Multi-User Pricing
  • Resources
    • Free Downloads
    • Excel Functions Explained
    • Excel Formulas
    • Excel Add-ins
    • IF Function
      • Excel IF Statement Explained
      • Excel IF AND OR Functions
      • IF Formula Builder
    • Time & Dates in Excel
      • Excel Date & Time
      • Calculating Time in Excel
      • Excel Time Calculation Tricks
      • Excel Date and Time Formatting
    • Excel Keyboard Shortcuts
    • Excel Custom Number Format Guide
    • Pivot Tables Guide
    • VLOOKUP Guide
    • ALT Codes
    • Excel VBA & Macros
    • Excel User Forms
    • VBA String Functions
  • Members
    • Login
    • Password Reset
  • Blog
  • Excel Webinars
  • Excel Forum
    • Register as Forum Member

Date Time Picker |VBA & Macros|Excel Forum|My Online Training Hub

You are here: Home / Date Time Picker |VBA & Macros|Excel Forum|My Online Training Hub
Avatar
sp_LogInOut Log In sp_Registration Register
sp_Search Search
Advanced Search
Search
Forum Scope




Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
sp_Search Search
sp_RankInfo
Lost password?
sp_CrumbsHome HomeExcel ForumVBA & MacrosDate Time Picker
sp_PrintTopic sp_TopicIcon
Date Time Picker
Avatar
CHRISTY RUS
Member
Members
Level 0
Forum Posts: 8
Member Since:
June 30, 2020
sp_UserOfflineSmall Offline
1
August 19, 2020 - 4:32 am
sp_Permalink sp_Print

I've added a date time picker to an Excel form to allow the user to choose a date rather than having to enter each time. When I first add the functionality only the date displays. When I close and open the file the field displays the date and time. How do I remove the time from the display?

Avatar
Philip Treacy
Admin
Level 10
Forum Posts: 1515
Member Since:
October 5, 2010
sp_UserOfflineSmall Offline
2
August 19, 2020 - 8:44 am
sp_Permalink sp_Print

Hi Christy,

Can't help you without your workbook, please attach it.

Phil

Avatar
CHRISTY RUS
Member
Members
Level 0
Forum Posts: 8
Member Since:
June 30, 2020
sp_UserOfflineSmall Offline
3
August 19, 2020 - 10:10 pm
sp_Permalink sp_Print sp_EditHistory

Phil, The spreadsheet is attached. I'm working in Excel 2010. Thanks

Avatar
Philip Treacy
Admin
Level 10
Forum Posts: 1515
Member Since:
October 5, 2010
sp_UserOfflineSmall Offline
4
August 25, 2020 - 11:56 am
sp_Permalink sp_Print

Hi Christy,

Something went wrong with that upload because the link doesn't work.  Can you try again please.

Phil

Avatar
CHRISTY RUS
Member
Members
Level 0
Forum Posts: 8
Member Since:
June 30, 2020
sp_UserOfflineSmall Offline
5
August 26, 2020 - 1:41 am
sp_Permalink sp_Print

Phil, I've attached the file again. Hope it works this time.

Avatar
CHRISTY RUS
Member
Members
Level 0
Forum Posts: 8
Member Since:
June 30, 2020
sp_UserOfflineSmall Offline
6
August 26, 2020 - 1:45 am
sp_Permalink sp_Print

I'm going to attach again, not sure why this isn't working properly.

Avatar
CHRISTY RUS
Member
Members
Level 0
Forum Posts: 8
Member Since:
June 30, 2020
sp_UserOfflineSmall Offline
7
August 26, 2020 - 1:47 am
sp_Permalink sp_Print

Phil, I keep getting an error message that the file is too large but it didn't happen this last time. Hope third times the charm. ThanksLaugh

Avatar
Philip Treacy
Admin
Level 10
Forum Posts: 1515
Member Since:
October 5, 2010
sp_UserOfflineSmall Offline
8
August 26, 2020 - 9:02 am
sp_Permalink sp_Print

Hi Christy,

If your file is too large to upload here then use OneDrive and share it.

That said, if you are using the code from here

https://www.myonlinetraininghu.....-userforms

it should already be just returning a date, no time component.

If you are getting a date.time returned then you can remove the time by using the INT or TRUNC functions before writing the value to the cell

https://www.myonlinetraininghu.....time-value

Regards

Phil

Avatar
CHRISTY RUS
Member
Members
Level 0
Forum Posts: 8
Member Since:
June 30, 2020
sp_UserOfflineSmall Offline
9
August 26, 2020 - 11:46 pm
sp_Permalink sp_Print

Phil, Thanks for the resources. One question, will these methods work for multiple cells in the workbook? Here is the code I set up to create a date picker in multiple cells in the workbook. Is it possible to add a line of code to ensure the date displays as a date only? It works when I first add the date picker to the cells but when I save the file and open it again, the cells display date and time.  

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

  With Sheet1.DTPicker1
    .Height = 20
    .Width = 20
    If Not Intersect(Target, Range("A:A")) Is Nothing Then
      .Visible = True
      .Top = Target.Top
      .Left = Target.Offset(0, 1).Left
      .LinkedCell = Target.Address
    Else
      .Visible = False
    End If
  End With

  With Sheet1.DTPicker2
    .Height = 20
    .Width = 20
    If Not Intersect(Target, Range("I:I")) Is Nothing Then
      .Visible = True
      .Top = Target.Top
      .Left = Target.Offset(0, 1).Left
      .LinkedCell = Target.Address
    Else
      .Visible = False
    End If
  End With

  With Sheet1.DTPicker3
    .Height = 20
    .Width = 20
    If Not Intersect(Target, Range("L:L")) Is Nothing Then
      .Visible = True
      .Top = Target.Top
      .Left = Target.Offset(0, 1).Left
      .LinkedCell = Target.Address
    Else
      .Visible = False
    End If
  End With
 
   With Sheet1.DTPicker4
    .Height = 20
    .Width = 20
    If Not Intersect(Target, Range("S:V")) Is Nothing Then
      .Visible = True
      .Top = Target.Top
      .Left = Target.Offset(0, 1).Left
      .LinkedCell = Target.Address
    Else
      .Visible = False
    End If
  End With
 
  With Sheet1.DTPicker5
    .Height = 20
    .Width = 20
    If Not Intersect(Target, Range("X:X")) Is Nothing Then
      .Visible = True
      .Top = Target.Top
      .Left = Target.Offset(0, 1).Left
      .LinkedCell = Target.Address
    Else
      .Visible = False
    End If
  End With
 
  With Sheet1.DTPicker6
    .Height = 20
    .Width = 20
    If Not Intersect(Target, Range("O:O")) Is Nothing Then
      .Visible = True
      .Top = Target.Top
      .Left = Target.Offset(0, 1).Left
      .LinkedCell = Target.Address
    Else
      .Visible = False
    End If
  End With
 
End Sub

In the properties window the Format is set to 3-dtpCustom and the CustomFormat is set to mm/dd/yyyy. I have tried setting the format to  1-dtpShort Date as well with no impact after I save the file and open it again.

Avatar
Philip Treacy
Admin
Level 10
Forum Posts: 1515
Member Since:
October 5, 2010
sp_UserOfflineSmall Offline
10
August 27, 2020 - 2:55 pm
sp_Permalink sp_Print

Hi Christy,

If you use the code I linked to it will solve your problems.  I've incorporated it into the attached file.

Double click a cell in Col A to display the date picker.  The date you pick is stored into the selected cell in Col A.

You'll find the event code in the Sheet1(Log) module.  Add other ranges/columns to enable them to use the date picker too - hopefully the comments in the code make it clear what to do.  If not just ask.

Regards

Phil

sp_Feed
Go to top
Forum Timezone: Australia/Brisbane
Most Users Ever Online: 245
Currently Online: Sally Riley, Ahmad Alkhuffash, Ramon Lagos
Guest(s) 10
Currently Browsing this Page:
1 Guest(s)
Top Posters:
SunnyKow: 1432
Anders Sehlstedt: 870
Purfleet: 412
Frans Visser: 346
David_Ng: 306
lea cohen: 219
A.Maurizio: 202
Jessica Stewart: 202
Aye Mu: 201
jaryszek: 183
Newest Members:
michael serna
mashal sana
Tiffany Kang
Leah Gillmore
Sopi Yuniarti
LAFONSO HERNANDEZ
Hayden Hao
Angela chen
Sean Moore
John Chisholm
Forum Stats:
Groups: 3
Forums: 24
Topics: 6214
Posts: 27246

 

Member Stats:
Guest Posters: 49
Members: 31897
Moderators: 3
Admins: 4
Administrators: Mynda Treacy, Philip Treacy, Catalin Bombea, FT
Moderators: MOTH Support, Velouria, Riny van Eekelen
© Simple:Press —sp_Information

Sidebar

Blog Categories

  • Excel
  • Excel Charts
  • Excel Dashboard
  • Excel Formulas
  • Excel PivotTables
  • Excel Shortcuts
  • Excel VBA
  • General Tips
  • Online Training
  • Outlook
  • Power Apps
  • Power Automate
  • Power BI
  • Power Pivot
  • Power Query
microsoft mvp logo
trustpilot excellent rating
Secured by Sucuri Badge
MyOnlineTrainingHub on YouTube Mynda Treacy on Linked In Mynda Treacy on Instagram Mynda Treacy on Twitter Mynda Treacy on Pinterest MyOnlineTrainingHub on Facebook
 

Company

  • About My Online Training Hub
  • Disclosure Statement
  • Frequently Asked Questions
  • Guarantee
  • Privacy Policy
  • Terms & Conditions
  • Testimonials
  • Become an Affiliate

Support

  • Contact
  • Forum
  • Helpdesk - For Technical Issues

Copyright © 2023 · My Online Training Hub · All Rights Reserved. Microsoft and the Microsoft Office logo are trademarks or registered trademarks of Microsoft Corporation in the United States and/or other countries. Product names, logos, brands, and other trademarks featured or referred to within this website are the property of their respective trademark holders.