Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

User Form Time Picker

Posted on 2014-04-23
5
Medium Priority
?
351 Views
Last Modified: 2014-04-25
I've tweaked some code for a pop up time picker I found here:

http://www.experts-exchange.com/Software/Office_Productivity/Office_Suites/MS_Office/Excel/Q_24868820.html

I'd like to have the time picker "remember" the value in the cell if I double click on it. Currently, I can change the time and it stays in the cell but if double click the cell again, it defaults back to 8:00 AM. In other words, if I change the time to 7:00 AM and double click the same cell, I want it to say 7:00 AM.

I've attached an example file. Thank you.
UserForm-Time-Question.xls
0
Comment
Question by:tracyms
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
5 Comments
 
LVL 52

Accepted Solution

by:
Rgonzo1971 earned 1200 total points
ID: 40019289
Hi,

pls try

Private Sub UserForm_Initialize()
     FrmTime.txtFollowupTime1.Locked = True
     FrmTime.txtFollowupTime1.Value = Format(TimeValue(ActiveCell), "hh:mmAM/PM")
     init_disp = Trim(FrmTime.txtFollowupTime1.Value)
End Sub

Open in new window

Regards
0
 
LVL 85

Assisted Solution

by:Rory Archibald
Rory Archibald earned 800 total points
ID: 40019970
You could use:
Private Sub UserForm_Initialize()
        
     With Me.txtFollowupTime1
        .Locked = True
        If Len(ActiveCell.Value) > 0 And IsDate(ActiveCell.Value) Then
            .Value = ActiveCell.Text
        Else
            .Value = Format(TimeSerial(8, 0, 0), "hh:mmAM/PM")
        End If
            init_disp = Trim(.Value)
    End With

End Sub

Open in new window


BTW, I think you want the Cancel = True in your BeforeDoubleClick code inside the If part rather than the Else part.
0
 
LVL 1

Author Comment

by:tracyms
ID: 40023844
Thanks! Both worked so I will divide the points. On another note - I'd love to have the same thing for dates. I've attached a sample I found on the Internet and will open another question if you're interested in solving it.
DateCombos.xlsm
0
 
LVL 1

Author Closing Comment

by:tracyms
ID: 40023845
I gave the first posted solution extra points since he was first. I hope this seems fair to you both. Thanks again!
0
 
LVL 1

Author Comment

by:tracyms
ID: 40023892
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
After seeing numerous questions for Dynamic Data Validation I notice that most have used Visual Basic to solve the problem. This suggestion is purely formula based and can be used in multiple rows.
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.

719 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question