+ Reply to Thread
Results 1 to 6 of 6

Create a Command Button

Hybrid View

  1. #1
    Registered User
    Join Date
    06-25-2007
    Location
    USA
    MS-Off Ver
    MS Office 2010
    Posts
    28

    Create a Command Button

    Hey there,

    I'm fairly decent with worksheet functions but not so good at the macro end of it. What im looking to do is create a button on the worksheet that displays the current time minus 3 minutes, when pressed. Also a button to do the same but only add 3 minutes when pressed.

    If you have any suggestions they would be greatly appreciated.

    Thank you,
    Nick

  2. #2
    Forum Expert
    Join Date
    12-10-2006
    Location
    Sydney
    MS-Off Ver
    Office 365
    Posts
    3,565
    Hi Nick,

    Let me know if the attached is what you need.

    HTH

    Robert
    Attached Files Attached Files

  3. #3
    Registered User
    Join Date
    06-25-2007
    Location
    USA
    MS-Off Ver
    MS Office 2010
    Posts
    28
    Yes and no,

    Instead of the promt coming up saying the adjusted time i was looking for it to enter it into a cell.


    TIA.

    Nick

  4. #4
    Forum Expert
    Join Date
    12-10-2006
    Location
    Sydney
    MS-Off Ver
    Office 365
    Posts
    3,565
    Hi Nick,

    You don't say which cell the time difference option should be returned to, so I've revamped the attached so that it returns the selected option to the cell the user was on (active cell) when they clicked the desired option (button).

    HTH

    Robert
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    06-25-2007
    Location
    USA
    MS-Off Ver
    MS Office 2010
    Posts
    28
    This will work. Thank you, though i'm wondering if i wanted it be in a specific cell where/how do i make it so. If you can adjust the one you've attached or show me the command i modify id like to be able to replicate this if need be.

    Thanks again for your help.


    Nick

  6. #6
    Forum Expert
    Join Date
    12-10-2006
    Location
    Sydney
    MS-Off Ver
    Office 365
    Posts
    3,565
    Hi Nick,

    The following will return the selected option to cell A1, change "A1" in the following code to suit:

    Sub Macro1()
    
        If InStr(Application.Caller, "Plus") > 0 Then
        Range("A1") = Format(Now + TimeSerial(0, 3, 0), "h:mm AM/PM")
        Else
        Range("A1") = Format(Now - TimeSerial(0, 3, 0), "h:mm AM/PM")
        End If
        
    End Sub
    HTH

    Robert

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1