Consulting

Page 2 of 2 FirstFirst 1 2
Results 21 to 27 of 27

Thread: Solved: Changing time string?

  1. #21
    Moderator VBAX Guru Simon Lloyd's Avatar
    Joined
    Sep 2005
    Location
    UK
    Posts
    3,003
    Location
    Bob that's perfect when the sheet in question is the activesheet, however this sheet is never available to the user, i adjusted it to this but it fails, could you tell me what i have missed?

    eFormula = "IF(OR(AND(MOD('Lookup List'!R1,1)>=--""06:15"",MOD('Lookup List'!R1,1)<=--""07:00""),AND(MOD('Lookup List'!R1,1)>=--""18:15"",MOD('Lookup List'!R1,1)<=--""19:00""))," & _
    "INT('Lookup List'!R1)+ROUNDDOWN(MOD('Lookup List'!R1,1)*4,0)/4,'Lookup List'!R1-""00:15"")-" & _
    "(NOT(OR(MOD('Lookup List'!R1,1)>=--""17:00"",MOD('Lookup List'!R1,1)<--""07:00"")))"

    As i said earlier this has been a development progression that has seen much redundant code...etc, however, i chose to evaluate as that eformula is used and referenced elsewhere in the code for days and nights
    Regards,
    Simon
    Please read this before cross posting!
    In the unlikely event you didn't get your answer here try Microsoft Office Discussion @ The Code Cage
    If I have seen further it is by standing on the shoulders of giants.
    Isaac Newton, Letter to Robert Hooke, February 5, 1675 English mathematician & physicist (1642 - 1727)

  2. #22
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    My guess Simon is that the addition of the sheet name makes the string to evaluate too long, you have added another 112 characters.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #23
    Moderator VBAX Guru Simon Lloyd's Avatar
    Joined
    Sep 2005
    Location
    UK
    Posts
    3,003
    Location
    Hi Bob, just been messing around with the sheets, i have now changed the forumla to use Now() instead of 'Lookup List'!R1, R1 was just a time and date generated from elsewhere at the time of the task being performed, so Now() sufficed and shaved a few bytes of the workbook

    Thanks for all your help, i must get you to explain the coercion and MOD if and when i get to attend any future conferences

    P.S it must have been the evaluation length, i did have a look round but couldn't find something concrete on the limitation unles it follows the 255 character rule, the evaluation length was 341
    Regards,
    Simon
    Please read this before cross posting!
    In the unlikely event you didn't get your answer here try Microsoft Office Discussion @ The Code Cage
    If I have seen further it is by standing on the shoulders of giants.
    Isaac Newton, Letter to Robert Hooke, February 5, 1675 English mathematician & physicist (1642 - 1727)

  4. #24
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    My thought was to create a function that returned the result, where the formula was evaluated in 3 parts and then compared in VBA. Not sure whether that would still work for you as you use it elsewhere.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  5. #25
    Moderator VBAX Guru Simon Lloyd's Avatar
    Joined
    Sep 2005
    Location
    UK
    Posts
    3,003
    Location
    The workaround using Now() has made me smarten more of the code up so i'm happy with that, i did think of putting it in a function but i felt it was somewhat a sledgehammer approach from my perspective as i really should be looking to reduce my code and not be so lazy!
    Regards,
    Simon
    Please read this before cross posting!
    In the unlikely event you didn't get your answer here try Microsoft Office Discussion @ The Code Cage
    If I have seen further it is by standing on the shoulders of giants.
    Isaac Newton, Letter to Robert Hooke, February 5, 1675 English mathematician & physicist (1642 - 1727)

  6. #26
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Putting code in functions is not lazy, abstractiing function ality is a god practice, especially where that code is obtuse far better not to clog up a main routine, just issue a call gto the side to do that 'nasty' work quietly and return a nice tidy result.

    But I fail; to see how Now works, I thought you were testing user entered values?
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  7. #27
    Moderator VBAX Guru Simon Lloyd's Avatar
    Joined
    Sep 2005
    Location
    UK
    Posts
    3,003
    Location
    Not too good at explaining myself Bob:
    R1 is originally a concatenation of Shift, Date & Time of an action performed, whilst developing i removed the shift to leave a date & time.

    Because of this thread it forced me to read over all the pages of code and follow the flow, it became apparent that i was always checking R1 and R1 was always NOW at the time of running the rest of the code which allowed me to clean up and get rid of superfluous code.

    As you knidly supplied a fix for my dilemma i have also now tidied up further and no longer use the original eFormula for insertion elsewhere but copy it from the location it already resides in then make the original cell = original.value, keeping the amoubnt of volatile formula to a minimum.

    You've been a great help.............see?
    Regards,
    Simon
    Please read this before cross posting!
    In the unlikely event you didn't get your answer here try Microsoft Office Discussion @ The Code Cage
    If I have seen further it is by standing on the shoulders of giants.
    Isaac Newton, Letter to Robert Hooke, February 5, 1675 English mathematician & physicist (1642 - 1727)

Posting Permissions

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