Solved

User Form Time Picker

Posted on 2014-04-23
5
327 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
  • 3
5 Comments
 
LVL 49

Accepted Solution

by:
Rgonzo1971 earned 300 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 200 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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
Do you use a spreadsheet like Microsoft's Excel?  Have you ever wanted to link out to a non excel file on your computer or network drive?  This is the way I found to do it!
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.

770 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