+ Reply to Thread
Results 1 to 5 of 5

Problem entering Time Data

  1. #1
    Valued Forum Contributor
    Join Date
    05-08-2012
    Location
    Georgia, USA
    MS-Off Ver
    Excel 2003, 2010
    Posts
    811

    Problem entering Time Data

    I would like to enter data in certain cells and have them converted to time format.

    For example, if I enter 730 in cell I17, I want it converted to 7:30.

    I tried to follow an example in CPearson.com but for some reason, it didn't work.


    Please Login or Register  to view this content.
    BTW: The range, I want this macro to work on is: Range I17:I20, B30:C32 and L39:41.
    I tried changing the A1:A10 above but it didn't work

    Can someone help?

    I have included an example file with the cells in question marked in yellow

    No sure what I am doing wrong

    Thanks
    Attached Files Attached Files
    Click on star (*) below if this helps

  2. #2
    Forum Expert JasperD's Avatar
    Join Date
    05-07-2013
    Location
    Netherlands
    MS-Off Ver
    Excel 2016
    Posts
    1,393

    Re: Problem entering Time Data

    Try this (worked for me )
    And please remember to put your code on the worksheet you're using instead of in a module.

    Please Login or Register  to view this content.
    Please click the * below if this helps

  3. #3
    Valued Forum Contributor
    Join Date
    11-20-2012
    Location
    Seattle, WA USA
    MS-Off Ver
    Excel 2010
    Posts
    597

    Re: Problem entering Time Data

    the original code works too, but JasperD is right, you need to have it in the sheet code, not a module, right click on the sheet tab and click view code, then paste it there

    i did it for you, so you can see where it goes, you will see that there are no modules, double click the actual sheet when you are in the vba editor
    test.xlsm

  4. #4
    Valued Forum Contributor
    Join Date
    05-08-2012
    Location
    Georgia, USA
    MS-Off Ver
    Excel 2003, 2010
    Posts
    811

    Re: Problem entering Time Data

    Pardon me. I am not well versed in Visual Basic. I understand how to add VBA code to an individual worksheets and know how to make a Visual Basic module but don't understand the difference between worksheet macros and module macros? How did you know this was a worksheet macro?

    I have a need to do this to multiple sheets. Would I have to duplicate this code for each worksheet? Could I make a module that is useable for multiple worksheets?

  5. #5
    Valued Forum Contributor
    Join Date
    11-20-2012
    Location
    Seattle, WA USA
    MS-Off Ver
    Excel 2010
    Posts
    597
    Worksheet code has a name worksheet_something, where as module code is any name, you can just put one line like call module as the code and it will run the module. Workssheet code is triggered by an event on that sheet,ie selection, change etc

+ 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