+ Reply to Thread
Results 1 to 8 of 8

Format Time in VBA not working correctly

  1. #1
    Registered User
    Join Date
    05-26-2015
    Location
    Portugal
    MS-Off Ver
    2010
    Posts
    5

    Format Time in VBA not working correctly

    Hello everyone,

    I have a problem which is i want to make a makro where i click and it saves a file with the date, Time and in this case a line (production).
    The date and the line when it saves it is correct, but the time stays in the format text! And i tried and tried and i still cant manage to bring it to format in time... I will leave here the code, if anyone can help me i would aprreciate a lot!

    Please Login or Register  to view this content.
    I should say that at R5 i have the funtion =JETZT which is =NOW, and as i said it saves everything fine but the time. here is how it is saving : 34-26.05.2015-42150,5572501157

    43 is the line
    26.05.2015 is the date
    42150,5572501157 and this is my problem...

    Ah and by some reason it says compatibility mode?

    Thanks in advance for the help!

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Format Time in VBA not working correctly

    JETZT doesn't mean anything in VBA, so it will be seen as an undeclared variable with no value.

    If you just want Filename3 to be the value from R5 formatted as time try this.
    Please Login or Register  to view this content.
    If that's not what you want can you explain further?
    If posting code please use code tags, see here.

  3. #3
    Registered User
    Join Date
    05-26-2015
    Location
    Portugal
    MS-Off Ver
    2010
    Posts
    5

    Re: Format Time in VBA not working correctly

    Thanks for the quick answer! I tried as you said but i got an error 1004?? Something about "The file could not be accessed"

    Please Login or Register  to view this content.
    But i get this yellow:

    Please Login or Register  to view this content.
    To explain better, now its 14:00 so i would like when i press the button that the file would save like 37-26.05.2015-14:00, beeing the 37 the line number, then the date and then the time. And the time should allways be diferent as the date!

    Thanks in advance!

  4. #4
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Format Time in VBA not working correctly

    37-26.05.2015-14:00 isn't a valid filename due to the : in the time.

  5. #5
    Registered User
    Join Date
    05-26-2015
    Location
    Portugal
    MS-Off Ver
    2010
    Posts
    5

    Re: Format Time in VBA not working correctly

    Then no problem it can be 14_00 or 14.00..

  6. #6
    Registered User
    Join Date
    05-26-2015
    Location
    Portugal
    MS-Off Ver
    2010
    Posts
    5

    Re: Format Time in VBA not working correctly

    Sorry not to say in the other reply, but if you know any other makro that can do what i need im completely fine with that!

    Thanks in advance!

  7. #7
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Format Time in VBA not working correctly

    Just replace the : with a suitable character.
    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    05-26-2015
    Location
    Portugal
    MS-Off Ver
    2010
    Posts
    5

    Re: Format Time in VBA not working correctly

    Thank You very Much, It worked like a charm!

    Thanks again!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Help with time calculations which are not working correctly
    By JillJ in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 03-21-2014, 07:07 AM
  2. [SOLVED] Formula to add network time to leave time not working correctly
    By mlm2832 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 02-27-2014, 12:45 AM
  3. Macro to format not working correctly...
    By misterGwhizz in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-13-2012, 05:21 PM
  4. Macro to format not working correctly...
    By misterGwhizz in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-13-2012, 12:15 PM
  5. Run time Error 91 - End Loop not working correctly
    By rowing190 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-05-2009, 05:18 PM

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