+ Reply to Thread
Results 1 to 5 of 5

Macro formats cells in some sheets, but doesn't format in some others... why?

  1. #1
    Registered User
    Join Date
    05-14-2008
    Posts
    56

    Macro formats cells in some sheets, but doesn't format in some others... why?

    Hello all, thanks in advance for reading.

    I have a macro to process some data, what it does is arrange a large chunk of raw data into separate sheets and dates/times, with proper formatting.

    The problem is, it formats "single-digit hour times" (8:00:00 AM, 9:30:10 PM) as General but formats "double-digit hour times" (10:00:00 AM) as Time correctly.

    To better understand this, please set a break point at line 59 and run the macro. The formatting section is from line 49-55. I'm using Excel 2007.

    How can I prevent the macro from incorrectly formatting cells as General? I need it to be formatted as Time (h:mm:ss)...

    Thanks a lot!
    Attached Files Attached Files

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689
    You are applying the formatting to the current selection on worksheet "myname" rather than explicitly specifying the range.

  3. #3
    Registered User
    Join Date
    05-14-2008
    Posts
    56
    thanks for your reply.

    i don't understand, how does this affect the formatting? besides, in some sheets where it contains both "single-digit-hours" and "double-digit-hours", it formats 9:00:00AM as General but 10:00:00AM as Time... I modified the source data to display 09:00:00AM but after processing it's still changed back to 9:00:00AM and formatted as General...

    appreciate all help!

  4. #4
    Registered User
    Join Date
    05-14-2008
    Posts
    56
    oh wait i suddenly figured it out! due to my programming of

    Please Login or Register  to view this content.
    so it pasted " 9:00:00AM" with a [space] at the front... no wonder it didnt format as time.

    so i'm guessing this can be fixed by removing the space... will try to search the forum if there's a pre-existing macro for that, but will appreciate all help nonetheless.

  5. #5
    Registered User
    Join Date
    05-14-2008
    Posts
    56
    edit: found. answer was

    Please Login or Register  to view this content.
    again, thanks for reading, sorry if you think i was spamming, the answer just came to me.

+ 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