Consulting

Results 1 to 5 of 5

Thread: Excel VBA code to Correct Day ?

  1. #1
    VBAX Regular
    Joined
    Oct 2010
    Posts
    26
    Location

    Excel VBA code to Correct Day ?

    Hi,

    we have a system that generates a report and a tool to manipulate the report to a easy reading format however the system that makes the reports is not great and causes some issues,

    i need to vba code to run on a column to correct days just wondering if theres code out there before i try re invent the wheel

    eg the roport gives us:

    DATETIMEDAY16/01/201223:54Mon16/01/201223:58Mon17/01/201200:03Mon17/01/201200:08Mon

    but i need code to check that and notice that it runs over midnight and corrects it to:

    DATETIMEDAY16/01/201223:54Mon16/01/201223:58Mon17/01/201200:03Tue17/01/201200:08Tue

    any suggestions welcomed ?

    EDIT tables doent seem to work i nthis board i ll try upload a sample file in a little bit
    https://www.rapidshare.com/#!download|33|1325602612|MidnightCode.zip|5
    Last edited by gunny2k9; 01-13-2012 at 09:34 AM.

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    [vba]
    Application.ScreenUpdating = False

    With Activesheet

    lastrow = .Cells(.Rows.Count, "A").End(xlUp).Row
    For i = 2 To LastRow

    .Cells(i, "B").Value = Format(.Cells(i, "A").Value, "ddd")
    Next i
    End With
    [/vba]
    ____________________________________________
    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. #3
    VBAX Regular
    Joined
    Oct 2010
    Posts
    26
    Location
    thanks xld that works,

    now i dont mean to be a pain in the butt here, but in some reports there is no date feild of eg 16/01/2012 dont suppose you know a ay to work it out with out that field ?

    if not not to worry i m sure i can figure something

  4. #4
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Not sure what you mean, as that looks like a date field to me.
    ____________________________________________
    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. #5
    Moderator VBAX Guru Simon Lloyd's Avatar
    Joined
    Sep 2005
    Location
    UK
    Posts
    3,003
    Location
    ...also, if the date field is missing there's nothing to correct
    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
  •